X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/84e0a92d17b4a782dee2c4b257ee0e5f66be9af6..a7d2c58f1476916c7781866ea55abeba9a12a18a:/edumed/contact_forms.py diff --git a/edumed/contact_forms.py b/edumed/contact_forms.py index 2cb7dd9..8358907 100644 --- a/edumed/contact_forms.py +++ b/edumed/contact_forms.py @@ -308,28 +308,20 @@ class OlimpiadaForm(ContactForm): def save(self, request, formsets=None): contact = super(OlimpiadaForm, self).save(request, formsets) - mail_subject = render_to_string('contact/olimpiada/student_mail_subject.html').strip() for formset in formsets or []: if formset.prefix == 'student': for f in formset.forms: email = f.cleaned_data.get('email', None) - try: - confirmation = Confirmation.objects.get(email=email) - except Confirmation.DoesNotExist: - first_name = f.cleaned_data.get('first_name', None) - last_name = f.cleaned_data.get('last_name', None) - confirmation = Confirmation.create( - first_name=first_name, last_name=last_name, email=email, contact=contact) - mail_body = render_to_string( - 'contact/olimpiada/student_mail_body.html', {'confirmation': confirmation}) - try: - validate_email(email) - except ValidationError: - pass - else: - send_mail(mail_subject, mail_body, 'olimpiada@nowoczesnapolska.org.pl', [email], - fail_silently=True) - + if email: + try: + Confirmation.objects.get(email=email) + except Confirmation.DoesNotExist: + first_name = f.cleaned_data.get('first_name', None) + last_name = f.cleaned_data.get('last_name', None) + if first_name and last_name: + confirmation = Confirmation.create( + first_name=first_name, last_name=last_name, email=email, contact=contact) + confirmation.send_mail() return contact