fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
563c90a
)
Split newsletter forms.
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 30 Jun 2020 09:09:57 +0000
(11:09 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Thu, 10 Sep 2020 12:15:11 +0000
(14:15 +0200)
src/newsletter/forms.py
patch
|
blob
|
history
src/newsletter/templates/newsletter/subscribe_form.html
patch
|
blob
|
history
src/newsletter/urls.py
patch
|
blob
|
history
src/newsletter/views.py
patch
|
blob
|
history
diff --git
a/src/newsletter/forms.py
b/src/newsletter/forms.py
index
1091ed8
..
acf2636
100644
(file)
--- a/
src/newsletter/forms.py
+++ b/
src/newsletter/forms.py
@@
-52,7
+52,7
@@
Więcej informacji w <a href="">polityce prywatności.</a>'''
# send_noreply_mail(
# ugettext('Confirm your subscription to Wolne Lektury newsletter'),
# render_to_string('newsletter/subscribe_email.html', {'subscription': subscription}), [email])
# send_noreply_mail(
# 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):
class SubscribeForm(NewsletterForm):
@@
-60,12
+60,9
@@
class SubscribeForm(NewsletterForm):
agree_newsletter = None
email = EmailField(label=_('email address'))
agree_newsletter = None
email = EmailField(label=_('email address'))
- mailing_lists = MultipleChoiceField(
- widget=CheckboxSelectMultiple,
- choices=(('general', _('general newsletter')), ('contest', _('about the contest'))),
- label=_('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)
super(SubscribeForm, self).__init__(*args, **kwargs)
diff --git
a/src/newsletter/templates/newsletter/subscribe_form.html
b/src/newsletter/templates/newsletter/subscribe_form.html
index
53d7901
..
6d9f3bc
100644
(file)
--- a/
src/newsletter/templates/newsletter/subscribe_form.html
+++ b/
src/newsletter/templates/newsletter/subscribe_form.html
@@
-10,7
+10,6
@@
{% render_honeypot_field %}
<ol>
<li>{{ form.email|pretty_field }}</li>
{% render_honeypot_field %}
<ol>
<li>{{ form.email|pretty_field }}</li>
- <li>{{ form.mailing_lists|pretty_field }}</li>
<li><span class="helptext">{{ form.data_processing }}</span></li>
<li><input type="submit" value="{% trans "Subscribe" %}"/></li>
</ol>
<li><span class="helptext">{{ form.data_processing }}</span></li>
<li><input type="submit" value="{% trans "Subscribe" %}"/></li>
</ol>
diff --git
a/src/newsletter/urls.py
b/src/newsletter/urls.py
index
bfae579
..
290bb87
100644
(file)
--- a/
src/newsletter/urls.py
+++ b/
src/newsletter/urls.py
@@
-6,6
+6,7
@@
from . import views
urlpatterns = [
path('zapisz-sie/', views.subscribe_form, name='subscribe'),
urlpatterns = [
path('zapisz-sie/', views.subscribe_form, name='subscribe'),
+ path('zapisz-sie/konkurs/', views.subscribe_form, {"title": "Zapisz się na newsletter Konkursu", "mailing_list": "contest"}, name='subscribe-contest'),
path('zapis/', views.subscribed, name='subscribed'),
path('potwierdzenie/<int:subscription_id>/<slug:hashcode>/',
views.confirm_subscription, name='confirm_subscription'),
path('zapis/', views.subscribed, name='subscribed'),
path('potwierdzenie/<int:subscription_id>/<slug:hashcode>/',
views.confirm_subscription, name='confirm_subscription'),
diff --git
a/src/newsletter/views.py
b/src/newsletter/views.py
index
4c57a25
..
6c90873
100644
(file)
--- a/
src/newsletter/views.py
+++ b/
src/newsletter/views.py
@@
-11,16
+11,16
@@
from newsletter.forms import UnsubscribeForm, SubscribeForm
from newsletter.models import Subscription
from newsletter.models import Subscription
-def subscribe_form(request):
+def subscribe_form(request
, mailing_list='general', title=None
):
if request.POST:
if request.POST:
- form = SubscribeForm(request.POST)
+ form = SubscribeForm(
mailing_list,
request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('subscribed'))
else:
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('subscribed'))
else:
- form = SubscribeForm()
+ form = SubscribeForm(
mailing_list
)
return render(request, 'newsletter/subscribe_form.html', {
return render(request, 'newsletter/subscribe_form.html', {
- 'page_title': _('Subscribe To Newsletter'),
+ 'page_title':
title or
_('Subscribe To Newsletter'),
'form': form,
})
'form': form,
})