4.2.2.12. Package apps.widgets.quests

quests module.

apps.widgets.quests.MAX_AVAILABLE_QUESTS = 3

The number of quests a user can have at any one time.

4.2.2.12.1. Module apps.widgets.quests.models

Defines the Quest Model.

class apps.widgets.quests.models.Quest(*args, **kwargs)[source]

Represents a quest in the database.

Parameters:
  • id (AutoField) – Id
  • name (CharField) – The name of the quest.
  • quest_slug (SlugField) – A unique identifier of the quest. Automatically generated if left blank.
  • description (TextField) – Discription of the quest. It should outline the steps to completing this quest. Uses Markdown formatting.
  • priority (IntegerField) – Quest with lower values (higher priority) will be listed first.
  • unlock_conditions (TextField) – Conditions a user needs to meet in order to have this quest be available (appeared in the Quest widget). Uses Makahiki Predicates.
  • completion_conditions (TextField) – Conditions a user needs to meet in order to complete the quest. Uses Makahiki Predicates.
accept(user)[source]

Lets the user accept the quest. Returns True if successful.

can_add_quest(user)[source]

Returns True if the user can add the quest.

completed_quest(user)[source]

Returns True if the user completed the quest.

opt_out(user)[source]

Lets the user opt out of seeing the quest. Returns True if successful.

class apps.widgets.quests.models.QuestMember(*args, **kwargs)[source]

Represents a user’s participation in a quest. Shouldn’t be in the admin interface, since there shouldn’t be a reason to edit instances.

Parameters:
  • id (AutoField) – Id
  • user_id (ForeignKey) – User
  • quest_id (ForeignKey) – Quest
  • completed (BooleanField) – True if the user completed the quest.
  • opt_out (BooleanField) – True if the user opts out of the quest.
  • created_at (DateTimeField) – Created at
  • updated_at (DateTimeField) – Updated at
delete(*args, **kwargs)[source]

Custom delete method.

save(*args, **kwargs)[source]

Custom save method to create a points transaction after the object is saved.

4.2.2.12.2. Module apps.widgets.quests.views

Implemenat view processing for Quests.

apps.widgets.quests.views.accept(request, *args, **kwargs)[source]

Accept the quest.

apps.widgets.quests.views.cancel(request, *args, **kwargs)[source]

cancel the quest

apps.widgets.quests.views.opt_out(request, *args, **kwargs)[source]

opt_out of the quest

apps.widgets.quests.views.supply(request, page_name)[source]

supply the quest view_objects

4.2.2.12.3. Module apps.widgets.quests.admin

Quest administrative interface, enabling checking of quest conditions.

class apps.widgets.quests.admin.QuestAdmin(model, admin_site)[source]

Admin

form

alias of QuestAdminForm

class apps.widgets.quests.admin.QuestAdminForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

admin form

class Meta[source]

meta

model

alias of Quest

QuestAdminForm.clean_completion_conditions()[source]

Validates the unlock conditions of the quest.

QuestAdminForm.clean_unlock_conditions()[source]

Validates the unlock conditions of the quest.

4.2.2.12.4. Module apps.widgets.quests.management.commands.verify_quests

Invocation: python manage.py verify_quests

Verifies that all of the existing quest lock and unlock condition strings are valid. Prints out the names of any invalid quest conditions.

class apps.widgets.quests.management.commands.verify_quests.Command(*args, **kwargs)[source]

command

handle(*args, **options)[source]