Texml
django-ssify>=0.2.1,<0.3
-raven
\ No newline at end of file
+raven
+
+mailchimp3
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from hashlib import md5
+
+import requests
+from django.conf import settings
+from mailchimp3 import MailChimp
+from mailchimp3.mailchimpclient import MailChimpError
+
+INTERESTS = {settings.MAILCHIMP_GROUP_ID: True}
+
+
+def get_client():
+ headers = requests.utils.default_headers()
+ headers['User-Agent'] = '%s (%s)' % settings.MANAGERS[0]
+
+
+def subscriber_hash(email):
+ return md5(email).hexdigest()
+
+
+def remove_from_groups(email, client):
+ group_ids = []
+ categories = client.lists.interest_categories.all(list_id=settings.MAILCHIMP_LIST_ID)['categories']
+ for category in categories:
+ groups = client.lists.interest_categories.interests.all(
+ list_id=settings.MAILCHIMP_LIST_ID, category_id=category['id'])['interests']
+ group_ids += [group['id'] for group in groups]
+ interests = {group_id: False for group_id in group_ids}
+ client.lists.members.update(
+ settings.MAILCHIMP_LIST_ID, subscriber_hash(email),
+ data={'interests': interests})
+
+
+def subscribe(email):
+ client = MailChimp(mc_api=settings.MAILCHIMP_API_KEY, timeout=10.0)
+ try:
+ member = client.lists.members.get(settings.MAILCHIMP_LIST_ID, subscriber_hash(email))
+ except MailChimpError:
+ pass
+ else:
+ if member['status'] != 'subscribed':
+ remove_from_groups(email, client)
+ client.lists.members.create_or_update(
+ settings.MAILCHIMP_LIST_ID, subscriber_hash(email),
+ data={
+ 'email_address': email,
+ 'status_if_new': 'subscribed',
+ 'status': 'subscribed',
+ 'interests': INTERESTS,
+ }
+ )
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _, ugettext
+from contact import mailing
from newsletter.models import Subscription
from wolnelektury.utils import send_noreply_mail
class NewsletterForm(Form):
email_field = 'email'
agree_newsletter = BooleanField(
- required=False, initial=True, label=_(u'I want to receive Wolne Lektury\'s newsletter.'), help_text='''\
+ required=False, initial=False, label=_(u'I want to receive Wolne Lektury\'s newsletter.'), help_text='''\
Oświadczam, że wyrażam zgodę na przetwarzanie moich danych osobowych zawartych \
w niniejszym formularzu zgłoszeniowym przez Fundację Nowoczesna Polska (administratora danych) z siedzibą \
w Warszawie (00-514) przy ul. Marszałkowskiej 84/92 lok. 125 w celu otrzymywania newslettera Wolnych Lektur. \
except ValidationError:
pass
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'),
- render_to_string('newsletter/subscribe_email.html', {'subscription': subscription}), [email])
+ # subscription, created = Subscription.objects.get_or_create(email=email, defaults={'active': False})
+ # send_noreply_mail(
+ # ugettext(u'Confirm your subscription to Wolne Lektury newsletter'),
+ # render_to_string('newsletter/subscribe_email.html', {'subscription': subscription}), [email])
+ mailing.subscribe(email)
class SubscribeForm(NewsletterForm):
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n"
"%100<10 || n%100>=20) ? 1 : 2);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Jan Szejko <jan.szejko@nowoczesnapolska.org.pl>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr "Chcę otrzymywać newsletter Wolnych Lektur"
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr "Potwierdź subskrypcję newslettera Wolnych Lektur"
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr "adres email"
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr "Nie znaleziono adresu email."
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr "Wypisuję się z newslettera Wolnych Lektur"
msgstr "Zapisz się"
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
-msgstr ""
-"Przyjęto zgłoszenie do subskrypcji newslettera Wolnych Lektur. Otrzymasz "
-"wiadomość z linkiem potwierdzającym na adres email."
+msgid "You have subscribed to Wolne Lektury newsletter."
+msgstr "Zapisałaś/eś się do newslettera Wolnych Lektur."
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgid "Unsubscribe"
msgstr "Zapisz się na newsletter"
#: views.py:28
-msgid "Confirmation link sent"
-msgstr "Wysłano link potwierdzający"
+#| msgid "Subscribe"
+msgid "Subscribed"
+msgstr "Zapisano do newslettera"
#: views.py:43
msgid "Subscription confirmed"
#: views.py:63
msgid "Unsubscribed"
msgstr "Usunięto subskrypcję"
+
+#~ msgid "Confirm your subscription to Wolne Lektury newsletter"
+#~ msgstr "Potwierdź subskrypcję newslettera Wolnych Lektur"
+
+#~ msgid ""
+#~ "You have requested subscription to Wolne Lektury newsletter. You'll "
+#~ "receive a confirmation link by email."
+#~ msgstr ""
+#~ "Przyjęto zgłoszenie do subskrypcji newslettera Wolnych Lektur. Otrzymasz "
+#~ "wiadomość z linkiem potwierdzającym na adres email."
+
+#~ msgid "Confirmation link sent"
+#~ msgstr "Wysłano link potwierdzający"
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-09-15 13:32+0200\n"
+"POT-Creation-Date: 2018-04-04 17:12+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
-#: forms.py:16
+#: forms.py:17
msgid "I want to receive Wolne Lektury's newsletter."
msgstr ""
-#: forms.py:39
-msgid "Confirm your subscription to Wolne Lektury newsletter"
-msgstr ""
-
-#: forms.py:44 forms.py:52 models.py:10
+#: forms.py:46 forms.py:54 models.py:10
msgid "email address"
msgstr ""
-#: forms.py:59
+#: forms.py:61
msgid "Email address not found."
msgstr ""
-#: forms.py:70
+#: forms.py:72
msgid "Unsubscribe from Wolne Lektury's newsletter."
msgstr ""
msgstr ""
#: templates/newsletter/subscribed.html:7
-msgid ""
-"You have requested subscription to Wolne Lektury newsletter. You'll receive "
-"a confirmation link by email."
+msgid "You have subscribed to Wolne Lektury newsletter."
msgstr ""
#: templates/newsletter/unsubscribe_form.html:13 views.py:56
msgstr ""
#: views.py:28
-msgid "Confirmation link sent"
+msgid "Subscribed"
msgstr ""
#: views.py:43
{% block body %}
<h1>{{ page_title }}</h1>
<p>
- {% trans "You have requested subscription to Wolne Lektury newsletter. You'll receive a confirmation link by email." %}
+ {% trans "You have subscribed to Wolne Lektury newsletter." %}
</p>
{% endblock %}
\ No newline at end of file
def subscribed(request):
return render(request, 'newsletter/subscribed.html', {
- 'page_title': _(u'Confirmation link sent'),
+ 'page_title': _(u'Subscribed'),
})