X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/875efc3090b43807d41438a98f3e84ceafecab51..8c60a1ba0c4b0d563a641ed2c4853cf17690f0ad:/src/newsletter/forms.py
diff --git a/src/newsletter/forms.py b/src/newsletter/forms.py
index d473cf3a8..acf263662 100644
--- a/src/newsletter/forms.py
+++ b/src/newsletter/forms.py
@@ -1,4 +1,6 @@
-# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.forms import Form, BooleanField, MultipleChoiceField
@@ -16,15 +18,15 @@ from wolnelektury.utils import send_noreply_mail
class NewsletterForm(Form):
email_field = 'email'
agree_newsletter = BooleanField(
- required=False, initial=False, label=_(u'I want to receive Wolne Lektury\'s newsletter.'))
+ required=False, initial=False, label=_('I want to receive Wolne Lektury\'s newsletter.'))
mailing = False
mailing_field = 'agree_newsletter'
- data_processing_part1 = u'''\
+ data_processing_part1 = '''\
Administratorem danych osobowych jest Fundacja Nowoczesna Polska (ul. MarszaÅkowska 84/92 lok. 125, 00-514 Warszawa).
Podanie danych osobowych jest dobrowolne.'''
- data_processing_part2 = u'''Dane sÄ
przetwarzane w zakresie niezbÄdnym do wysyÅania newslettera odbiorcom.'''
- data_processing_part3 = u'''\
+ data_processing_part2 = '''Dane sÄ
przetwarzane w zakresie niezbÄdnym do wysyÅania newslettera odbiorcom.'''
+ data_processing_part3 = '''\
Osobom, których dane sÄ
zbierane, przysÅuguje prawo dostÄpu do treÅci swoich danych oraz ich poprawiania.
WiÄcej informacji w polityce prywatnoÅci.'''
@@ -48,9 +50,9 @@ WiÄcej informacji w polityce prywatnoÅci.'''
else:
# subscription, created = Subscription.objects.get_or_create(email=email, defaults={'active': False})
# send_noreply_mail(
- # ugettext(u'Confirm your subscription to Wolne Lektury newsletter'),
+ # ugettext('Confirm your subscription to Wolne Lektury newsletter'),
# render_to_string('newsletter/subscribe_email.html', {'subscription': subscription}), [email])
- mailing.subscribe(email, mailing_lists=self.cleaned_data.get('mailing_lists'))
+ mailing.subscribe(email, mailing_lists=[self.mailing_list])
class SubscribeForm(NewsletterForm):
@@ -58,12 +60,9 @@ class SubscribeForm(NewsletterForm):
agree_newsletter = None
email = EmailField(label=_('email address'))
- mailing_lists = MultipleChoiceField(
- widget=CheckboxSelectMultiple,
- choices=(('general', _(u'general newsletter')), ('contest', _(u'about the contest'))),
- label=_(u'mailing list'))
- def __init__(self, *args, **kwargs):
+ def __init__(self, mailing_list, *args, **kwargs):
+ self.mailing_list = mailing_list
super(SubscribeForm, self).__init__(*args, **kwargs)
@@ -75,7 +74,7 @@ class UnsubscribeForm(Form):
try:
subscription = Subscription.objects.get(email=email)
except Subscription.DoesNotExist:
- raise ValidationError(ugettext(u'Email address not found.'))
+ raise ValidationError(ugettext('Email address not found.'))
self.cleaned_data['subscription'] = subscription
def save(self):
@@ -87,6 +86,6 @@ class UnsubscribeForm(Form):
context = {'subscription': subscription}
# refactor to send_noreply_mail
send_noreply_mail(
- ugettext(u'Unsubscribe from Wolne Lektury\'s newsletter.'),
+ ugettext('Unsubscribe from Wolne Lektury\'s newsletter.'),
render_to_string('newsletter/unsubscribe_email.html', context),
[subscription.email], fail_silently=True)