# 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):
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)
{% 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>
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'),
from newsletter.models import Subscription
-def subscribe_form(request):
+def subscribe_form(request, mailing_list='general', title=None):
if request.POST:
- form = SubscribeForm(request.POST)
+ form = SubscribeForm(mailing_list, request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('subscribed'))
else:
- form = SubscribeForm()
+ form = SubscribeForm(mailing_list)
return render(request, 'newsletter/subscribe_form.html', {
- 'page_title': _('Subscribe To Newsletter'),
+ 'page_title': title or _('Subscribe To Newsletter'),
'form': form,
})