From b2579d9bb692cf293f8dea475103c60b286980b0 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 7 Jan 2019 11:07:02 +0100 Subject: [PATCH] fix email to teachers (don't send to None) --- stage2/management/commands/stage2_email_teachers.py | 2 +- wtem/management/commands/wtem_email_teachers.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stage2/management/commands/stage2_email_teachers.py b/stage2/management/commands/stage2_email_teachers.py index 35c136c..79e75c2 100644 --- a/stage2/management/commands/stage2_email_teachers.py +++ b/stage2/management/commands/stage2_email_teachers.py @@ -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') diff --git a/wtem/management/commands/wtem_email_teachers.py b/wtem/management/commands/wtem_email_teachers.py index c8e95c3..b2f1314 100644 --- a/wtem/management/commands/wtem_email_teachers.py +++ b/wtem/management/commands/wtem_email_teachers.py @@ -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: -- 2.20.1