From 297e48d3c1b26b83366b27cc4ba960c8471b634b Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 20 Oct 2022 11:45:21 +0200 Subject: [PATCH] Introducing new layout generic forms. --- src/newsletter/forms.py | 2 +- .../newsletter/2022/subscribe_form.html | 47 +++++++++++++++++++ src/newsletter/views.py | 9 +++- src/wolnelektury/static/2022/more.scss | 16 +++++++ src/wolnelektury/templates/2022/form.html | 19 ++++++++ 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/newsletter/templates/newsletter/2022/subscribe_form.html create mode 100644 src/wolnelektury/templates/2022/form.html diff --git a/src/newsletter/forms.py b/src/newsletter/forms.py index 47606a57f..4e42ae605 100644 --- a/src/newsletter/forms.py +++ b/src/newsletter/forms.py @@ -25,7 +25,7 @@ Podanie danych osobowych jest dobrowolne.''' 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.''' +Więcej informacji w polityce prywatności.''' @property def data_processing(self): diff --git a/src/newsletter/templates/newsletter/2022/subscribe_form.html b/src/newsletter/templates/newsletter/2022/subscribe_form.html new file mode 100644 index 000000000..d3b573bbe --- /dev/null +++ b/src/newsletter/templates/newsletter/2022/subscribe_form.html @@ -0,0 +1,47 @@ +{% extends "2022/base.html" %} +{% load i18n %} +{% load honeypot %} + + +{% block content %} +
+ +
+ +
+
+
+
+

{{ page_title }}

+
+
+ +
+
+
+
+
+ {% csrf_token %} + {% render_honeypot_field %} + {{ form }} + +
+ {{ form.data_processing }} +
+ +
+
+ +
+
+ +
+
+
+
+
+
+{% endblock %} diff --git a/src/newsletter/views.py b/src/newsletter/views.py index fcb9d3c80..6c2be8a6c 100644 --- a/src/newsletter/views.py +++ b/src/newsletter/views.py @@ -11,6 +11,7 @@ from newsletter.forms import SubscribeForm, Newsletter def subscribe_form(request, slug=''): newsletter = get_object_or_404(Newsletter, slug=slug) + new_layout = request.EXPERIMENTS['layout'].value if request.POST: form = SubscribeForm(newsletter, request.POST) if form.is_valid(): @@ -18,7 +19,13 @@ def subscribe_form(request, slug=''): return HttpResponseRedirect(reverse('subscribed')) else: form = SubscribeForm(newsletter) - return render(request, 'newsletter/subscribe_form.html', { + + if new_layout: + template_name = 'newsletter/2022/subscribe_form.html' + form.template_name = '2022/form.html' + else: + template_name = 'newsletter/subscribe_form.html' + return render(request, template_name, { 'page_title': newsletter.page_title, 'form': form, }) diff --git a/src/wolnelektury/static/2022/more.scss b/src/wolnelektury/static/2022/more.scss index d1deb7873..89621ce50 100644 --- a/src/wolnelektury/static/2022/more.scss +++ b/src/wolnelektury/static/2022/more.scss @@ -258,3 +258,19 @@ body.is-open { } } } + + +form { + .required { + label:before { + content: "* "; + color: #FF4C54; + } + } + .helptext { + color: #808080; + font-size: 15px; + line-height: 150%; + margin-bottom: 30px; + } +} diff --git a/src/wolnelektury/templates/2022/form.html b/src/wolnelektury/templates/2022/form.html new file mode 100644 index 000000000..156985b08 --- /dev/null +++ b/src/wolnelektury/templates/2022/form.html @@ -0,0 +1,19 @@ +{% if errors %} + {{ errors }} + {% if not fields %} + {% endif %} +{% endif %} +{% for field in hidden_fields %}{{ field }}{% endfor %} +{% for field, errors in fields %} +
+
+ {{ errors }} + {% if field.label %}{{ field.label_tag }}{% endif %} + {# * #} + {{ field }} + {# field.help_text|safe #} +
+
+
+
+{% endfor %} -- 2.20.1