4.5. Supported Predicates

This section documents the predicates available for evaluating conditions such as unlocking smartgrid levels, actions, quests, badges etc.

Note

This documentation is extracted automatically from the predicate definition source files. For this reason, the documentation shows the full path to the predicates. To use the predicates in a condition string, only the predicate name (without any qualified prefixes) should be used. In addition, the “user” argument need not to be supplied in the condition string. The predicates can be connected using python boolean operators such as “and” or “or” etc.

Example: The following condition string will check for if the current time has reach round 2 and the user has earned 100 points:

reached_round("Round 2") or has_points(100)

4.5.1. Challenge Predicates

Predicates regarding the state of the challenge.

apps.managers.challenge_mgr.predicates.game_enabled(user, name)[source]

Returns True if the game is enabled.

apps.managers.challenge_mgr.predicates.reached_round(user, name)[source]

Returns True if the current time was past the start of specified round.

4.5.2. Player Predicates

Predicates providing information about the state of the current player.

apps.managers.player_mgr.predicates.allocated_ticket(user)[source]

Returns True if the user has any allocated tickets.

apps.managers.player_mgr.predicates.badge_awarded(user, badge_slug)[source]

Returns True if the badge is awarded to the user.

apps.managers.player_mgr.predicates.change_theme(user)[source]

returns True if the user change their theme.

apps.managers.player_mgr.predicates.daily_energy_goal_count(user, count)[source]

Returns True if the number of consecutively meeting daily energy goal equals to count.

apps.managers.player_mgr.predicates.daily_visit_count(user, count)[source]

Returns True if the number of the user daily visit equals to count.

apps.managers.player_mgr.predicates.has_points(user, points)[source]

Returns True if the user has more than the specified points.

apps.managers.player_mgr.predicates.is_admin(user)[source]

Returns True if the user is an admin.

apps.managers.player_mgr.predicates.posted_to_wall(user)[source]

Returns True if the user posted to their wall and False otherwise.

apps.managers.player_mgr.predicates.referring_count(user, count)[source]

Returns True if the user have referred at least [count] new players.

apps.managers.player_mgr.predicates.set_profile_pic(user)[source]

Returns True if the user posted to their wall and False otherwise.

apps.managers.player_mgr.predicates.team_member_point_percent(user, points, percent)[source]

Returns True if the user’s team has at least [percent] members got at least [points].

4.5.3. Smart Grid Game Predicates

Predicates indicating if a level or cell should be unlocked.

apps.widgets.smartgrid.predicates.approved_action(user, slug)[source]

Returns true if the action is approved.

apps.widgets.smartgrid.predicates.approved_all_of(user, category_slug=None, action_type=None, resource=None, level_name=None)[source]

Returns true if all actions of the specified type is approved.

apps.widgets.smartgrid.predicates.approved_some_of(user, some=1, category_slug=None, action_type=None, resource=None, level_name=None)[source]

Returns true if some actions of the specified type is approved.

apps.widgets.smartgrid.predicates.completed_action(user, slug)[source]

Returns true if the user complete the action.

apps.widgets.smartgrid.predicates.completed_all_of(user, category_slug=None, action_type=None, resource=None, level_name=None)[source]

Returns true if completed all of the specified type.

apps.widgets.smartgrid.predicates.completed_level(user, lvl=1)[source]

Returns true if the user has performed all activities successfully, and attempted all commitments.

apps.widgets.smartgrid.predicates.completed_some_full_spectrum(user, some=1)[source]

Returns true if the user has completed some activities, commitments, and events.

apps.widgets.smartgrid.predicates.completed_some_of(user, some=1, category_slug=None, action_type=None, resource=None, level_name=None)[source]

Returns true if completed some of the specified type. some is default to 1 if not specified.

apps.widgets.smartgrid.predicates.completed_some_of_level(user, some=1, level_name=None)[source]

Returns true if completed some of the specified level.

apps.widgets.smartgrid.predicates.social_bonus_count(user, count)[source]

Returns True if the number of social bonus the user received equals to count.

apps.widgets.smartgrid.predicates.unlock_on_date(user, date_string)[source]

Returns true if the current date is equal to or after the date_string.

apps.widgets.smartgrid.predicates.unlock_on_event(user, event_slug, days=0, lock_after_days=0)[source]

Returns true if the current date is equal to or after the date of the Event defined by the event_slug, optionally days before. days should be a negative number. Optionally lock_after_days, if not zero then will return false lock_after_days after the event.