Skip to main content

The missing gamification plugin for Django

Project description

PyPI version Build Status Downloads

Django Gamification aims to fill the gamification sized hole in the Django package ecosystem. In the current state, Django Gamification provides a set of models that can be used to implement gamification features in your application. These include a centralised interface for keeping track of all gamification related objects including badges, points, and unlockables.

Example App

An example app can be found here.

Installation

Download from PyPI:

pip install django-gamification

And add to your INSTALLED_APPS:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    .
    .
    .
    'django_gamification'
]

Features and Examples

Concepts

Django Gamification requires the understanding of a few core concepts.

  • BadgeDefinitions: A template used to create new Badges and update existing Badges.

  • Badge: An object that represents some achievable objective in the system that can award points and track its own progression.

  • UnlockableDefinition: A template used to create new Unlockables and update existing Unlockables.

  • Unlockable: An object that is achieved by some accumulation of points.

  • Category: An object used to label other objects like Badges via their BadgeDefinition.

Interfaces

Creating an interface

from django.contrib.auth.models import User
from django.db import models
from django_gamification.models import GamificationInterface

class YourUserModel(User):
    # Your user fields here

    # The gamification interface
    interface = models.ForeignKey(GamificationInterface)

BadgeDefinitions and Badges

Creating a new badge

By creating a new BadgeDefinition, Django Gamification will automatically create Badge instances for all your current GamificationInterfaces with Badge.name, Badge.description, Badge.points, Badge.progression and Badge.category mimicking the fields on the BadgeDefinition.

from django_gamification.models import BadgeDefinition, Category

BadgeDefinition.objects.create(
    name='Badge of Awesome',
    description='You proved your awesomeness',
    points=50,
    progression_target=100,
    category=Category.objects.create(name='Gold Badges', description='These are the top badges'),
)

Awarding a badge

You can manually award a Badge instance using Badge.award().

from django_gamification.models import Badge

badge = Badge.objects.first()
# badge.acquired = False

badge.award()
# badge.acquired = True

UnlockableDefinitions and Unlockables

Creating a new unlockable

By creating a new UnlockableDefinition, Django Gamification will automatically create Unlockable instances for all your current GamificationInterfaces with Unlockable.name, Unlockable.description, Unlockable.points_required mimicking the fields on the UnlockableDefinition.

from django_gamification.models import UnlockableDefinition

UnlockableDefinition.objects.create(
    name='Some super sought after feature',
    description='You unlocked a super sought after feature',
    points_required=100
)

Contributing

Submitting an issue or feature request

If you find an issue or have a feature request please open an issue at Github Django Gamification Repo.

Working on issues

If you think that you can fix an issue or implement a feature, please make sure that it isn’t assigned to someone or if it is you may ask for an update.

Once an issue is complete, open a pull request so that your contribution can be reviewed. A TravisCI build will run and be attached to your pull request. Your code must pass these checks.

Get Started!

Ready to contribute? Here’s how to set up django-gamification for local development.

  1. Fork the django-gamification repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/django-gamification.git
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv django-gamification
    $ cd django-gamification/
    $ python setup.py develop
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ py.test
    $ tox

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
  7. Submit a pull request through the GitHub website.

Helping others

At all times, please be polite with others who are working on issues. It may be their first ever patch and we want to foster a friendly and familiar open source environment.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_gamification-0.3.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

django_gamification-0.3.2-py2.py3-none-any.whl (17.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django_gamification-0.3.2.tar.gz.

File metadata

  • Download URL: django_gamification-0.3.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.4

File hashes

Hashes for django_gamification-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fdbdce212032db75fc47b0f45124a6b94e74832b8a261fa6ae109440fd32f4d1
MD5 1db584da8466b31a9547b29b913a272a
BLAKE2b-256 8fbe478be5e715eb1488eddc0bb4d28fd7381554f9f2e88880cd65b0bfe65582

See more details on using hashes here.

File details

Details for the file django_gamification-0.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: django_gamification-0.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.4

File hashes

Hashes for django_gamification-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 823a4f4535148b3fa64afa0440032fddb6af372d3fbb5ad1321e90568ed1e708
MD5 0411082925e207767aec83d047397258
BLAKE2b-256 ae87bb256c7ba26057ac83c6892c9422aaacb0b0e3884ad3e97636a9d4f41b23

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page