-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
management command to check and assign credits for a nested event
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
tendenci/apps/events/management/commands/check_and_assign_credits.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Check and assign credits to registrants for a nested event. | ||
Usage: | ||
./manage.py check_and_assign_credits --event_id=<event-id> --verbosity=2 | ||
""" | ||
def add_arguments(self, parser): | ||
parser.add_argument('--event_id', | ||
dest='event_id', | ||
default=None, | ||
help='The id of the event to be checked') | ||
|
||
def handle(self, *args, **options): | ||
from tendenci.apps.events.models import Event, RegistrantChildEvent | ||
|
||
verbosity = options['verbosity'] | ||
event_id = options['event_id'] | ||
if not Event.objects.filter(id=event_id).exists(): | ||
print('Event with event id ', event_id, "doesn't exist. Exiting") | ||
return | ||
|
||
event = Event.objects.get(id=event_id) | ||
for child_event in event.all_child_events: | ||
if verbosity >= 2: | ||
print('Processing child event:', child_event) | ||
for c_registrant in RegistrantChildEvent.objects.filter( | ||
child_event=child_event, | ||
checked_in=True): | ||
if verbosity >= 2: | ||
print(c_registrant.registrant) | ||
child_event.assign_credits(c_registrant.registrant) | ||
|
||
print('Done') |