fix email to teachers (don't send to None) olimpiada
authorJan Szejko <janek37@gmail.com>
Mon, 7 Jan 2019 10:07:02 +0000 (11:07 +0100)
committerJan Szejko <janek37@gmail.com>
Mon, 7 Jan 2019 10:07:02 +0000 (11:07 +0100)
stage2/management/commands/stage2_email_teachers.py
wtem/management/commands/wtem_email_teachers.py

index 35c136c..79e75c2 100644 (file)
@@ -12,7 +12,7 @@ class Command(BaseCommand):
         sent = 0
         failed = 0
 
-        query = Participant.objects.order_by('contact__contact').distinct('contact__contact')\
+        query = Participant.objects.exclude(contact=None).order_by('contact__contact').distinct('contact__contact')\
             .values_list('contact__contact', flat=True)
         template_name = args[0]
         message = render_to_string('stage2/' + template_name + '.txt')
index c8e95c3..b2f1314 100644 (file)
@@ -12,7 +12,8 @@ class Command(BaseCommand):
         sent = 0
         failed = 0
 
-        contacts = Contact.objects.filter(form_tag='olimpiada').order_by('contact').distinct('contact')
+        contacts = Contact.objects.filter(form_tag='olimpiada').exclude(contact=None).order_by('contact')\
+            .distinct('contact')
         template_name = args[0]
         emails = args[1:]
         if emails: