X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/53907d17526cecf92207417e051527c00bcd2426..130e1c7f8c43261d0e85e5ff9a354f037bb7cd24:/wtem/management/commands/wtem_send_keys.py diff --git a/wtem/management/commands/wtem_send_keys.py b/wtem/management/commands/wtem_send_keys.py index 82e7469..05ffcbb 100644 --- a/wtem/management/commands/wtem_send_keys.py +++ b/wtem/management/commands/wtem_send_keys.py @@ -1,7 +1,12 @@ +# -*- coding: utf-8 -*- + +import sys from optparse import make_option from django.core.management.base import BaseCommand, CommandError from django.conf import settings +from wtem.management.commands import send_mail +from django.template.loader import render_to_string from wtem.models import Submission, DEBUG_KEY @@ -44,9 +49,9 @@ class Command(BaseCommand): try: self.send_key(submission) - except: + except Exception as e: failed += 1 - self.stdout.write('failed sending to: ' + submission.email) + self.stdout.write('failed sending to: ' + submission.email + ' - ' + str(e)) else: submission.key_sent = True submission.save() @@ -56,4 +61,9 @@ class Command(BaseCommand): self.stdout.write('sent: ' + str(sent)) def send_key(self, submission): - self.stdout.write('>>> sending to ' + submission.email) \ No newline at end of file + self.stdout.write('>>> sending to ' + submission.email) + send_mail( + subject = "WTEM - Twój link do zadań", + body = render_to_string('wtem/email_key.txt', dict(submission = submission)), + to = [submission.email] + ) \ No newline at end of file