Skip to content

Custom Management Commands

yongwen edited this page Oct 15, 2011 · 5 revisions

The system has a few useful Django management commands that will make some tasks easier. For more information on custom Django management commands, including how to write them, consult [the Django documentation] (https://docs.djangoproject.com/en/1.3/howto/custom-management-commands/).

##regenerate_codes (slug1 slug2 ...) Implemented in apps/components/activities/management/regenerate_codes.py

Regenerate the confirmation codes for activities that use confirmation codes. The amount of codes generated is based on the activity's 'event_max_seat' attribute. By default, this command will regenerate codes for all activities with confirmation codes. The command also takes optional parameters to delete the codes for an activity with the specified slug(s).

##add_codes num_codes slug1 (slug2 ...) Implemented in apps/components/activities/management/add_codes.py

Add num_codes to activities with the specified slug(s).

##send_reminders Implemented in apps/components/activities/management/send_reminders.py

Sends any unsent reminders at the time this script is written. Meant to be run every hour to send email/text reminders.

##add_points username points short-message long-message Implemented in apps/components/makahiki_base/management/add_points.py

Give the user additional points. short-message is stored in the PointTransaction log and displayed in 'My Achievements'. long-message is displayed in a user notification.

##add_points residence-hall floor-number points short-message long-message Implemented in apps/components/makahiki_base/management/add_points.py

Give the members of the residence-hall and floor-number additional points. short-message is stored in the PointTransaction log and displayed in 'My Achievements'. long-message is displayed in a user notification.

load_users filename

Implemented in apps/components/makahiki_base/management/load_users.py

Load and create the users from a csv file containing lounge, name, and email. if the second argument is RA, the csv file is the RA list, consists of name, email, lounge.

reset_competition

Implemented in apps/components/makahiki_base/management/reset_competition.py

Restores the competition to a pristine state. This means that all wall posts, activity/commitment/quest members, email/text reminders, raffle tickets, energy goals, and badge awards are deleted. Points for every user for every round are also set to 0.

##reset_user username1 (username2 ...) Implemented in apps/components/makahiki_base/management/reset_user.py

Takes usernames as arguments and resets each user, preserving their username, first and last name, email address, display name, admin status, and floor/lounge.

Example usage:

python manage.py reset_user user

sim_competition

Implemented in apps/components/makahiki_base/management/sim_competition.py

Simulates activity in the competition up to round 2. Has not been run in a while and may need an update.

validate_users

Implemented in apps/components/makahiki_base/management/validate_users.py

Validates usernames of users and makes sure they are unique. Also checks if any users have multiple profiles.

##pick_winners Implemented in apps/components/prizes/management/pick_winners.py

Picks raffle winners for any raffle prizes whose raffle deadline has passed and has not yet been assigned a winner.

##verify_quests Implemented in apps/components/quests/management/verify_quests.py

This command goes through the existing quests and applies their unlock and completion condition strings to a random user. The command will report the condition strings that do not validate.

Example usage:

python manage.py verify_quests

Clone this wiki locally