X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/d83b04cb2d40247e0c61ad7d01369207c6de96e1..010b648653d39191fb25b93424d408a95289826e:/edumed/contact_forms.py diff --git a/edumed/contact_forms.py b/edumed/contact_forms.py index 8629dce..196e5e4 100644 --- a/edumed/contact_forms.py +++ b/edumed/contact_forms.py @@ -10,8 +10,6 @@ from django.core.validators import validate_email from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ -from wtem.models import Confirmation - WOJEWODZTWA = ( u'dolnośląskie', u'kujawsko-pomorskie', @@ -272,6 +270,8 @@ class OlimpiadaForm(ContactForm): u'oświadczam, że zostałam/em poinformowana/y o tym, że mam prawo wglądu w treść swoich danych ' u'i możliwość ich poprawiania oraz że ich podanie jest dobrowolne, ale niezbędne do dokonania ' u'zgłoszenia.') + zgoda_newsletter = forms.BooleanField( + label=u'Chcę otrzymywać newsletter: Edukacja medialna', required=False) extract_types = (dict(slug='extended', label=_('extended')),) @@ -306,20 +306,23 @@ class OlimpiadaForm(ContactForm): return toret def save(self, request, formsets=None): + from wtem.models import Confirmation contact = super(OlimpiadaForm, self).save(request, formsets) for formset in formsets or []: if formset.prefix == 'student': for f in formset.forms: email = f.cleaned_data.get('email', None) - 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) - confirmation = Confirmation.create( - first_name=first_name, last_name=last_name, email=email, contact=contact) - confirmation.send_mail() + 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