X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/46ec8f39ae3e726a294a2288e51354ff834ba45e..18ecb6c6e58f9b273636f80f485e749a97ebdf60:/wtem/management/commands/notify_teachers.py?ds=sidebyside diff --git a/wtem/management/commands/notify_teachers.py b/wtem/management/commands/notify_teachers.py index 6e1e994..e7d3db0 100644 --- a/wtem/management/commands/notify_teachers.py +++ b/wtem/management/commands/notify_teachers.py @@ -9,7 +9,9 @@ from wtem.management.commands import send_mail from wtem.models import Confirmation -THRESHOLD = 3 +THRESHOLD = 0 + +AFTER_DEADLINE = True class Command(BaseCommand): @@ -19,7 +21,7 @@ class Command(BaseCommand): query = Contact.objects.filter(form_tag='olimpiada').order_by('contact').distinct('contact') template_name = 'notify_unconfirmed' - message_template = 'wtem/' + template_name + '.txt' + message_template = 'wtem/' + template_name + ('_after' if AFTER_DEADLINE else '') + '.txt' subject = render_to_string('wtem/' + template_name + '_subject.txt') threshold = timezone.now() - timedelta(THRESHOLD) @@ -28,8 +30,10 @@ class Command(BaseCommand): unconfirmed = [] contacts = [] for similar_contact in Contact.objects.filter(contact=contact.contact, form_tag=contact.form_tag): + contact_emails = [s['email'] for s in similar_contact.body.get('student', [])] new_unconfirmed = list(Confirmation.objects.filter( - contact=similar_contact, confirmed=False, contact__created_at__lt=threshold)) + contact=similar_contact, confirmed=False, contact__created_at__lt=threshold, + email__in=contact_emails)) unconfirmed += new_unconfirmed if new_unconfirmed: contacts.append(similar_contact)