From ff6b3c61fefe067e73adb8bc076ffd8792c6ad5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 16 Dec 2013 15:30:02 +0100 Subject: [PATCH 1/1] send_results: --only-to flag --- wtem/management/commands/wtem_send_results.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wtem/management/commands/wtem_send_results.py b/wtem/management/commands/wtem_send_results.py index 94c2653..c0da6fd 100644 --- a/wtem/management/commands/wtem_send_results.py +++ b/wtem/management/commands/wtem_send_results.py @@ -30,6 +30,11 @@ class Command(BaseCommand): dest='to_students', default=False, help='Send emails to students'), + make_option('--only-to', + action='store', + dest='only_to', + default=None, + help='Send emails to students'), ) def handle(self, *args, **options): @@ -45,6 +50,8 @@ class Command(BaseCommand): subject = 'Twój wynik w I etapie Wielkiego Turnieju Edukacji Medialnej' for submission in get_submissions(): + if options['only_to'] and submission.email != options['only_to']: + continue final_result = submission.final_result if final_result < minimum: template = 'results_student_failed.txt' @@ -55,7 +62,7 @@ class Command(BaseCommand): self.sum_up() - def handle_to_teachers(self, *args, **kwargs): + def handle_to_teachers(self, *args, **options): self.stdout.write('>>> Sending results to teachers') subject = 'Wyniki Twoich uczniów w I etapie Wielkiego Turnieju Edukacji Medialnej' failed = sent = 0 @@ -63,6 +70,8 @@ class Command(BaseCommand): submissions_by_contact = dict() for submission in get_submissions(): + if options['only_to'] and submission.contact.contact != options['only_to']: + continue submissions_by_contact.setdefault(submission.contact.id, []).append(submission) for contact_id, submissions in submissions_by_contact.items(): -- 2.20.1