Introducing new layout generic forms.
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 20 Oct 2022 09:45:21 +0000 (11:45 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 20 Oct 2022 09:45:21 +0000 (11:45 +0200)
src/newsletter/forms.py
src/newsletter/templates/newsletter/2022/subscribe_form.html [new file with mode: 0644]
src/newsletter/views.py
src/wolnelektury/static/2022/more.scss
src/wolnelektury/templates/2022/form.html [new file with mode: 0644]

index 47606a5..4e42ae6 100644 (file)
@@ -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 <a href="">polityce prywatności.</a>'''
+Więcej informacji w <a href="https://nowoczesnapolska.org.pl/prywatnosc/">polityce prywatności.</a>'''
 
     @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 (file)
index 0000000..d3b573b
--- /dev/null
@@ -0,0 +1,47 @@
+{% extends "2022/base.html" %}
+{% load i18n %}
+{% load honeypot %}
+
+
+{% block content %}
+  <div class="l-container">
+    <div class="l-breadcrumb">
+      <a href="/"><span>Strona główna</span></a>
+      <a>{{ page_title }}</a>
+    </div>
+  </div>
+
+  <main class="l-main">
+    <div class="l-checkout__box" style="margin-bottom: 70px;">
+      <div class="l-checkout__box__header">
+        <div class="l-checkout__box__header__content">
+          <h1>{{ page_title }}</h1>
+        </div>
+      </div>
+
+      <div class="l-checkout__cols">
+        <div class="l-checkout__col"></div>
+        <div class="l-checkout__col">
+          <form method="post">
+            <div class="l-checkout__form">
+              {% csrf_token %}
+              {% render_honeypot_field %}
+              {{ form }}
+
+              <div class="helptext">
+                {{ form.data_processing }}
+              </div>
+
+              <div class="l-checkout__form__row confirm">
+                <div class="l-checkout__input">
+                  <button style="margin-left:0">Dalej</button>
+                </div>
+              </div>
+
+            </div>
+          </form>
+        </div>
+      </div>
+    </div>
+  </main>
+{% endblock %}
index fcb9d3c..6c2be8a 100644 (file)
@@ -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,
     })
index d1deb78..89621ce 100644 (file)
@@ -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 (file)
index 0000000..156985b
--- /dev/null
@@ -0,0 +1,19 @@
+{% if errors %}
+  {{ errors }}
+  {% if not fields %}
+  {% endif %}
+{% endif %}
+{% for field in hidden_fields %}{{ field }}{% endfor %}
+{% for field, errors in fields %}
+  <div class="l-checkout__form__row {% if field.field.required %}required {% endif %} {{ field.css_classes }}">
+    <div class="l-checkout__input">
+      {{ errors }}
+      {% if field.label %}{{ field.label_tag }}{% endif %}
+      {# <span>*</span> #}
+      {{ field }}
+      {# field.help_text|safe #}
+    </div>
+    <div class="l-checkout__input">
+    </div>
+  </div>
+{% endfor %}