Skip to content
Snippets Groups Projects
Commit 74049a0b authored by jindra12's avatar jindra12 Committed by jan.bednarik
Browse files

Start fixing errors found after migration

parent bdb1ad81
Branches
No related tags found
2 merge requests!804Release,!779Add basic newsletter form FE support
......@@ -43,6 +43,7 @@ from shared.blocks import (
FooterLinksBlock,
FullSizeHeaderBlock,
HeadlineBlock,
NewsletterSubscriptionBlock,
YouTubeVideoBlock,
)
from shared.const import RICH_TEXT_DEFAULT_FEATURES
......@@ -100,6 +101,7 @@ class DistrictHomePage(
),
),
("headline", HeadlineBlock()),
("newsletter", NewsletterSubscriptionBlock()),
],
verbose_name="Obsah stránky",
blank=True,
......@@ -1406,7 +1408,11 @@ class DistrictCrossroadPage(
class DistrictCustomPage(
ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, Page
ExtendedMetadataPageMixin,
SubpageMixin,
MetadataPageMixin,
NewsletterFormMixin,
Page,
):
### FIELDS
......@@ -1415,6 +1421,7 @@ class DistrictCustomPage(
+ [
("badge", blocks.PersonBadgeBlock()),
("people_group", blocks.PeopleGroupListBlock()),
("newsletter", NewsletterSubscriptionBlock()),
],
verbose_name="Obsah",
blank=True,
......@@ -1429,7 +1436,7 @@ class DistrictCustomPage(
promote_panels = make_promote_panels()
settings_panels = []
settings_panels = NewsletterFormMixin.settings_panels
### RELATIONS
......
......@@ -352,7 +352,7 @@
<script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script>
<script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script>
<script src="{% static "shared/vendor/fancybox/jquery.fancybox.min.js" %}"></script>
<script src="{% static "shared/vendor/vue-formulate-2.5.3/js/formulate.umd.min.js" %}"></script>
<script src="{% static "shared/vendor/vue-formulate-2.5.3/js/formulate.min.js" %}"></script>
<script src="{% static "shared/vendor/vue-formulate-i18n-1.16.0/js/cs.min.js" %}"></script>
<script src="{% static "shared/js/vue-formulate-helper.js" %}"></script>
......
......@@ -1076,24 +1076,53 @@ class FooterLinksBlock(blocks.StructBlock):
class NewsletterSubscriptionBlock(blocks.StructBlock):
design = blocks.StructBlock(
local_blocks=[
("icon", ImageChooserBlock(label="Vyberte si ikonku k formuláři")),
("title", blocks.CharBlock(label="Nadpis formuláře")),
("subtitle", blocks.CharBlock(label="Podnadpis formuláře")),
(
"icon",
ImageChooserBlock(
label="Vyberte si ikonku k formuláři",
required=False,
help_text="Pokud žádnou nevyberete, zobrazí se ikonka pro lahev v moři",
),
),
(
"title",
blocks.CharBlock(
label="Nadpis formuláře", default="Odebírej náš newsletter"
),
),
(
"subtitle",
blocks.CharBlock(
label="Podnadpis formuláře",
default="Fake news tam nenajdeš, ale dozvíš se, co chystáme doopravdy!",
),
),
(
"consent",
blocks.RichTextBlock(label="Souhlas se zpracováním osobních údajů"),
blocks.RichTextBlock(
label="Souhlas se zpracováním osobních údajů",
features=RICH_TEXT_DEFAULT_FEATURES,
default="Souhlasím se zpracováním osobních údajů",
),
),
(
"button",
blocks.CharBlock(
label="Tlačítko pro přihlášení k newsletteru", default="Odebírat"
),
),
("button", blocks.CharBlock(label="Tlačítko pro přihlášení k newsletteru")),
(
"require_confirmation",
blocks.CharBlock(
label="Zpráva o úspěšném zaslání potvrzovacího emailu"
label="Zpráva o úspěšném zaslání potvrzovacího emailu",
default="Zkontroluj si prosím schránku, poslali jsme ti potvrzovací e-mail.",
),
),
(
"no_require_confirmation",
blocks.CharBlock(
label="Zpráva o úspěšném zaregistrování k newsletteru",
default="Jsi přihlášen/a k odběru našich novinek.",
help_text="Zobrazí se pouze pokud od uživatele nepožadujeme ověřovací email",
),
),
......@@ -1101,36 +1130,33 @@ class NewsletterSubscriptionBlock(blocks.StructBlock):
"labels",
blocks.StructBlock(
local_blocks=[
("email", blocks.CharBlock(label="Popisek emailu")),
(
"email",
blocks.CharBlock(
label="Popisek emailu", default="Tvůj e-mail"
),
),
(
"first_name",
blocks.CharBlock(label="Popisek křestního jména"),
blocks.CharBlock(
label="Popisek křestního jména",
default="Tvoje křestní jméno",
help_text="Zobrazí se, pouze pokud umožníte zadat jméno v konfiguraci",
),
("last_name", blocks.CharBlock(label="Popisek příjmení")),
],
default=[
("email", "Tvůj e-mail"),
("first_name", "Tvoje křestní jméno"),
("last_name", "Tvoje příjmení"),
],
label="popisky vstupů uživatele",
required=True,
),
(
"last_name",
blocks.CharBlock(
label="Popisek příjmení",
default="Tvoje příjmení",
help_text="Zobrazí se, pouze pokud umožníte zadat jméno v konfiguraci",
),
),
],
default=[
("title", "Odebírej náš newsletter"),
(
"subtitle",
"Fake news tam nenajdeš, ale dozvíš se, co chystáme doopravdy!",
label="popisky vstupů uživatele",
required=True,
),
("consent", "Souhlasím se zpracováním osobních údajů"),
(
"require_confirmation",
"Zkontroluj si prosím schránku, poslali jsme ti potvrzovací e-mail.",
),
("no_require_confirmation", "Jsi přihlášen/a k odběru našich novinek."),
("button", "Odebírat"),
],
label="Design formuláře",
required=True,
......@@ -1149,6 +1175,7 @@ class NewsletterSubscriptionBlock(blocks.StructBlock):
blocks.BooleanBlock(
label="Přihlásit uživatele, i když se v minulosti odhlásil?",
required=False,
default=True,
),
),
(
......@@ -1159,17 +1186,13 @@ class NewsletterSubscriptionBlock(blocks.StructBlock):
),
),
],
default=[
("show_name_input", False),
("force_subscribe", True),
("send_timezone", False),
],
label="Konfigurace",
required=True,
)
class Meta:
label = "Formulář pro odebírání newsletteru"
help_text = "Formulář bude fungovat pouze pokud nastavíte token a ID newsletteru v nastavení homepage, nebo této stránky"
icon = "form"
template = "shared/blocks/newsletter_subscription_block.html"
......
import logging
from django.core.serializers.json import DjangoJSONEncoder
from django.db import models
from django.http import JsonResponse
from django.http import HttpResponse
from django.utils import timezone
from requests import request
from wagtail.admin.panels import FieldPanel, MultiFieldPanel, PublishingPanel
......@@ -21,10 +20,14 @@ logger = logging.getLogger(__name__)
class NewsletterFormMixin(RoutablePageMixin, models.Model):
subscription_id = models.CharField(label="ID newsletteru")
access_token = models.CharField(label="Access token")
subscription_id = models.CharField(
verbose_name="ID newsletteru", max_length=512, null=True, blank=True
)
access_token = models.CharField(
verbose_name="Access token", max_length=512, null=True, blank=True
)
require_confirmation = models.BooleanField(
label="Požadovat zaslání ověřovacího e-mailu?", default=True
verbose_name="Požadovat zaslání ověřovacího e-mailu?", default=True
)
settings_panels = [
......@@ -32,13 +35,15 @@ class NewsletterFormMixin(RoutablePageMixin, models.Model):
[
FieldPanel("subscription_id"),
FieldPanel("access_token"),
FieldPanel("require_confirmation"),
],
heading="Nastavení API newsletteru",
"Nastavení API newsletteru",
),
]
@route(r"^newsletter/$", name="newsletter")
def newsletter_post(self, posted):
client_response = HttpResponse()
if posted.method == "POST":
mailtrain_request = {"EMAIL": posted.POST["email"]}
if "first_name" in posted.POST and "last_name" in posted.POST:
......@@ -58,15 +63,24 @@ class NewsletterFormMixin(RoutablePageMixin, models.Model):
mailtrain_request.update({"TIMEZONE": posted.POST["timezone"]})
if self.require_confirmation:
mailtrain_request.update({"REQUIRE_CONFIRMATION": "yes"})
return JsonResponse(
request(
response = request(
"POST",
f"https://mailtrain.pirati.cz/api/subscribe/{self.subscription_id}?access_token={self.access_token}",
mailtrain_request,
).json(),
encoder=DjangoJSONEncoder,
)
raise ValueError("Request has to be post!")
if "error" in response.json():
client_response.status_code = 500
else:
client_response.status_code = response.status_code
return client_response
client_response.status_code = 400
return client_response
@property
def has_newsletter_form(self):
return True
class Meta:
abstract = True
......
<svg id="Group_50" data-name="Group 50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="158.03" height="200.379" viewBox="0 0 158.03 200.379">
<defs>
<clipPath id="clip-path">
<rect id="Rectangle_71" data-name="Rectangle 71" width="158.03" height="200.379"/>
</clipPath>
</defs>
<g id="Group_49" data-name="Group 49" clip-path="url(#clip-path)">
<path id="Path_533" data-name="Path 533" d="M39.771,27.6a23.544,23.544,0,0,0,2.3-.938c.546-.291.947-.2,1.153.416.06.179.243.311.335.484.453.86.882,1.733,1.344,2.588.5.93,1.042,1.839,1.543,2.769.131.242.144.548.276.788a16.3,16.3,0,0,0,1.323,2.774c.548.679.6,1.737,1.069,2.505.505.824.67,1.829,1.457,2.518.318.278.357.859.566,1.282.439.892.866,1.794,1.373,2.648a7.67,7.67,0,0,0,2.465,2.777,4.724,4.724,0,0,0,1.645.665c.791.131,1.613.063,2.419.117,1.979.132,3.966.213,5.932.456a28.476,28.476,0,0,1,3.628.863,13.474,13.474,0,0,1,2.078.647c1.086.482,2.133,1.052,3.19,1.6.634.327,1.278.643,1.876,1.027.671.43,1.264.985,1.946,1.392a21.184,21.184,0,0,1,3.523,3.169c.15.142.434.142.52.326.482.578.973,1.149,1.445,1.736q.622.773,1.21,1.574c.242.329.468.672.679,1.022.375.624.738,1.257,1.1,1.889.392.689.787,1.377,1.159,2.076.335.631.616,1.292.968,1.913s.78,1.17,1.121,1.782c.381.684.691,1.407,1.048,2.1.382.745.788,1.477,1.174,2.221.256.493.492,1,.739,1.494.345.695.683,1.394,1.042,2.082.379.725.78,1.439,1.17,2.158.263.484.529.967.784,1.456.309.591.6,1.189.911,1.781.439.845.87,1.694,1.331,2.527.351.635.759,1.238,1.114,1.871.337.6.64,1.225.953,1.841.323.635.629,1.279.96,1.909.754,1.437,1.533,2.862,2.271,4.307.366.717.644,1.479,1,2.2.253.512.568.994.862,1.485.234.39.5.761.718,1.161.712,1.323,1.419,2.65,2.1,3.988.355.7.642,1.428.989,2.129.224.451.51.871.752,1.314.12.22.2.459.3.69.264.608.517,1.222.8,1.823.329.71.681,1.411,1.024,2.115.322.66.626,1.33.973,1.977a19.682,19.682,0,0,0,1.607,2.8c.7.9.61,2.186,1.571,2.914-.125.994.859,1.505,1.04,2.4a6.216,6.216,0,0,0,.926,1.6c.3.518.57,1.051.93,1.719.188-.087.445-.218.711-.325a1.153,1.153,0,0,1,.464-.1,3.513,3.513,0,0,0,2.156-.8c1.011-.67,2.1-1.221,3.128-1.866a14.624,14.624,0,0,0,2.193-1.549c1.631-1.506,3.254-3.03,4.761-4.657a10.073,10.073,0,0,0,2.119-2.784,10.5,10.5,0,0,1,.967-1.334,18,18,0,0,0,1.082-1.887c.532-1.109,1.025-2.238,1.5-3.373a12.411,12.411,0,0,0,.467-1.481c.328-1.178.655-2.356.958-3.539.169-.659.271-1.335.434-1.995.224-.912.508-1.809.706-2.726.1-.459.028-.952.095-1.421a54.43,54.43,0,0,0,.517-6.861,23.07,23.07,0,0,1,.454-3.073c.55,0,1.162-.008,1.773,0a34.859,34.859,0,0,1,4.633.12c3.237.49,6.487.183,9.725.375a.7.7,0,0,1,.582,1.083,1.2,1.2,0,0,0-.064.486c-.038,1.617-.025,3.237-.118,4.851a22.316,22.316,0,0,1-.492,4.42c-.252.95-.177,1.881-.343,2.807-.17.948-.291,1.9-.462,2.852a17.355,17.355,0,0,1-.434,1.926c-.352,1.17-.779,2.318-1.123,3.491-.171.582-.156,1.222-.35,1.793-.364,1.068-.826,2.1-1.234,3.155-.185.479-.3.989-.514,1.451-.506,1.082-1.062,2.14-1.583,3.215-.351.724-.648,1.475-1.024,2.185a8.4,8.4,0,0,1-1.033,1.583,6.469,6.469,0,0,0-1.144,1.771c-.119.286-.469.466-.664.732-.878,1.193-1.69,2.437-2.619,3.588a27.966,27.966,0,0,1-2.292,2.37,36.861,36.861,0,0,1-3.3,3.067,21.88,21.88,0,0,0-1.808,1.443,18.383,18.383,0,0,1-1.672,1.323c-.42.311-.861.593-1.3.878-.764.5-1.534.985-2.3,1.477-.292.187-.576.39-.88.555-.768.418-1.546.817-2.317,1.228s-1.511.838-2.282,1.224c-.7.35-1.425.646-2.132.978s-1.4.678-2.1,1.014c-.174.083-.356.15-.533.228-.547.24-1.09.489-1.641.72-.5.208-.992.414-1.5.589-.934.321-1.878.616-2.816.928-1.277.424-2.561.828-3.826,1.285-.955.345-1.885.76-2.827,1.141a.744.744,0,0,1-.141.021c-1.5.28-3.01.528-4.5.853-.756.165-1.482.467-2.221.707a.57.57,0,0,1-.07.012c-.97.179-1.945.334-2.908.545s-1.909.48-2.863.722c-.069.017-.141.021-.211.033l-2.349.38c-.48.832-.836,1.5-1.242,2.143-.43.677-.908,1.323-1.363,1.984-.333.483-.661.968-.993,1.451-.423.616-.824,1.25-1.279,1.841-.38.494-.854.915-1.231,1.41-.613.805-1.154,1.665-1.775,2.464-.411.529-.939.966-1.36,1.489-.8.989-1.555,2.01-2.327,3.02-.041.053-.047.153-.095.176-1.021.482-1.417,1.585-2.267,2.258a26.9,26.9,0,0,0-2.3,2.289c-1.179,1.192-2.312,2.436-3.556,3.555-.776.7-1.739,1.186-2.584,1.814-.5.367-.876.9-1.395,1.222a19.6,19.6,0,0,1-2.423,1.729,14.1,14.1,0,0,0-1.947,1.392c-.835.553-1.7,1.06-2.564,1.571-.664.394-1.326.8-2.017,1.138-.651.321-1.343.559-2.011.847-.933.4-1.849.843-2.793,1.216-.586.232-1.212.363-1.815.554-.425.135-.844.29-1.263.443-.309.113-.606.26-.92.354-.922.276-1.851.533-2.777.8a.644.644,0,0,1-.07.012c-.879.156-1.76.305-2.638.469a31.416,31.416,0,0,1-6,.516c-.551,0-1.108.288-1.655.266a66.054,66.054,0,0,1-6.926-.459c-1-.148-2.016-.191-3.013-.363-.835-.144-1.674-.269-2.5-.449-1.17-.254-2.334-.539-3.495-.832-1.048-.264-2.1-.528-3.132-.844-.61-.187-1.183-.49-1.783-.713a13.275,13.275,0,0,0-1.479-.468c-1.207-.293-2.426-.544-3.632-.841-.387-.1-.924-.183-1.082-.454a1.95,1.95,0,0,1-.093-1.328c.142-.569.514-1.076.7-1.639.363-1.115.612-2.269,1.007-3.371.294-.82.762-1.575,1.118-2.374a10.745,10.745,0,0,0,.454-1.336c.186-.632.309-1.285.532-1.9.322-.892.72-1.757,1.062-2.642a5.27,5.27,0,0,0,.173-.815c.146-.69.552-.835,1.192-.6,1.012.377,2.064.644,3.091.983.63.208,1.243.467,1.864.7a1.05,1.05,0,0,0,.27.065,7.671,7.671,0,0,1,2.844.841.746.746,0,0,0,.281.026,10.44,10.44,0,0,1,3.416.833.517.517,0,0,0,.141.014,43.808,43.808,0,0,1,5.13.593,18.038,18.038,0,0,0,4.449.238,33.427,33.427,0,0,0,4.5-.426,23.4,23.4,0,0,0,3.349-.844c1.17-.365,2.329-.785,3.457-1.265.721-.307,1.34-.871,2.072-1.125a4.9,4.9,0,0,0,1.662-.84.721.721,0,0,0,.182-.983c-.47-1.088-1.078-2.117-1.545-3.206-.4-.928-.662-1.912-1-2.866-.08-.224-.255-.414-.34-.636-.474-1.234-.9-2.488-1.412-3.705-.3-.7-.758-1.336-1.086-2.029-.22-.464-.318-.985-.5-1.467-.265-.685-.578-1.351-.839-2.036-.567-1.49-1.092-3-1.675-4.478-.347-.884-.784-1.732-1.154-2.608-.211-.5-.315-1.048-.559-1.527a25.187,25.187,0,0,0-1.536-3.446,7.633,7.633,0,0,1-.565-1.515c-.388-.937-.823-1.854-1.2-2.8-.219-.544-.329-1.133-.551-1.676-.358-.876-.781-1.725-1.151-2.6a17.58,17.58,0,0,0-.97-2.355c-.428-.7-.351-1.6-1.1-2.2-.353-.283-.282-1.058-.485-1.578-.19-.488-.5-.929-.736-1.4-.321-.629-.621-1.268-.942-1.9-.381-.746-.781-1.481-1.16-2.227-.334-.657-.649-1.324-.977-1.983-.117-.236-.256-.461-.372-.7-.163-.331-.3-.679-.474-1q-.686-1.255-1.4-2.492c-.2-.337-.457-.638-.641-.98-.483-.9-.918-1.824-1.412-2.717-.612-1.108-1.277-2.188-1.894-3.294-.348-.623-.62-1.289-.971-1.91-.334-.59-.762-1.128-1.087-1.723-.385-.7-.7-1.45-1.055-2.17s-.738-1.4-1.083-2.115c-.214-.442-.381-.905-.565-1.361-.267-.659-.541-1.316-.794-1.981-.167-.44-.313-.888-.449-1.338-.171-.564-.343-1.128-.48-1.7-.278-1.163-.564-2.326-.782-3.5a9.3,9.3,0,0,1-.076-1.709,59.873,59.873,0,0,1,.1-6.627,8.436,8.436,0,0,1,1.074-3.936,3.461,3.461,0,0,0,.448-1.4,9.245,9.245,0,0,1,1.239-2.87c.227-.435.321-.936.522-1.386.534-1.2,1.11-2.373,1.635-3.573a9.538,9.538,0,0,0,.473-1.479,21.61,21.61,0,0,1,.551-2.334,11.031,11.031,0,0,0,.3-4.856,5.538,5.538,0,0,0-.634-1.646c-.14-.323-.353-.615-.482-.941A16.158,16.158,0,0,0,24.7,54.57c-.387-.732-.878-1.409-1.319-2.112a.323.323,0,0,1-.011-.171c.009-.171.1-.405.022-.5-.771-.948-.973-2.249-1.918-3.091-.1-.087-.051-.321-.11-.471a7.187,7.187,0,0,0-.414-.9c-.3-.527-.647-1.028-.932-1.563-.082-.153.039-.41-.032-.575-.293-.677-.62-1.339-.944-2-.344-.7-.692-1.406-1.052-2.1a4.609,4.609,0,0,0-.379-.544c-.488-.68-.274-1.128.575-1.314a9.635,9.635,0,0,0,1.47-.493c.048-.019.046-.388-.01-.412-.455-.193-.934-.325-1.394-.508-.925-.368-1.838-.765-2.764-1.132-.481-.191-.977-.344-1.467-.514a4.107,4.107,0,0,0-1.271-.412c-1.149.022-1.251-.876-1.6-1.6s-.759-1.422-1.161-2.121c-.386-.67-.814-1.315-1.191-1.99-.475-.853-.9-1.736-1.38-2.584-.305-.536-.7-1.019-1.023-1.546C6.01,25.28,5.673,24.628,5.3,24c-.191-.322-.432-.614-.625-.935-.362-.6-.7-1.223-1.058-1.83-.245-.417-.517-.82-.756-1.24-.34-.6-.657-1.209-.992-1.81C1.415,17.37.947,16.565.495,15.751A7.678,7.678,0,0,1,0,14.724c-.019-.051.223-.283.356-.294a3.92,3.92,0,0,0,1.7-.759,11.3,11.3,0,0,1,1.525-.554c.94-.391,1.858-.833,2.8-1.222.5-.207,1.04-.32,1.542-.525.9-.368,1.78-.78,2.673-1.161.476-.2.967-.372,1.444-.573.736-.311,1.466-.636,2.2-.954.2-.086.4-.169.594-.255q.79-.344,1.578-.69c.079-.035.147-.1.228-.123A14.7,14.7,0,0,0,19.564,6.6a14.737,14.737,0,0,1,2.907-1.1c.868-.3,1.667-.793,2.513-1.163.473-.207.994-.3,1.469-.507.874-.372,1.723-.8,2.6-1.175.492-.211,1.018-.342,1.513-.546.921-.379,1.825-.8,2.749-1.175.545-.22,1.116-.376,1.675-.564a.95.95,0,0,0,.375-.149c.4-.409.569-.2.719.221.38,1.067.81,2.118,1.159,3.194.193.6.2,1.253.4,1.846.353,1.053.809,2.072,1.179,3.12.219.621.333,1.278.538,1.9s.474,1.239.7,1.862q.275.765.512,1.543c.326,1.07.616,2.152.971,3.212.189.563.564,1.07.7,1.639a1.9,1.9,0,0,1-.185,1.8,3.267,3.267,0,0,0-.522,1.588,10.289,10.289,0,0,1-1.242,3.457,10.858,10.858,0,0,0-.521,1.989M70,81.91c.227-.077.528-.086.6-.222a5.645,5.645,0,0,0,.878-1.86,5.735,5.735,0,0,0-.282-3.49,3.778,3.778,0,0,0-3.049-2.118,63.3,63.3,0,0,0-6.9-.069.937.937,0,0,0-.282.029c-.765.247-1.525.51-2.292.75-1.036.323-2.1.561-3.109.958-1.368.541-2.69,1.2-4.033,1.8a6.311,6.311,0,0,0-.813.345c-.955.606-1.909,1.217-2.836,1.867a20.913,20.913,0,0,0-2.083,1.619c-.606.551-1.1,1.228-1.685,1.8a15.277,15.277,0,0,0-2.574,3.462c-.407.715-.642,1.527-.979,2.285a4.587,4.587,0,0,0-.5,2.8c.2,1.189,1.138,1.732,1.731,2.557.646.9,1.669,1.428,2.4,2.328.669.825,1.2,1.9,2.242,2.415.049.024.07.115.092.18.472,1.413,1.623,2.381,2.371,3.616.416.687.982,1.281,1.423,1.955.6.912,1.136,1.861,1.7,2.793.424.7.868,1.392,1.266,2.107.334.6.609,1.232.919,1.846s.643,1.223.951,1.841c.479.961.967,1.919,1.407,2.9.231.513.342,1.078.549,1.6.506,1.282,1.087,2.536,1.543,3.835.381,1.087.646,2.216.928,3.335.2.774.332,1.563.5,2.345a2.685,2.685,0,0,0,.082.266c.256.789.52,1.575.765,2.367.18.582.315,1.178.506,1.756.2.608.5,1.189.656,1.806.231.888.378,1.8.564,2.7a1.28,1.28,0,0,0,.083.189c.241.623.509,1.237.712,1.872s.3,1.289.5,1.915c.462,1.411.978,2.8,1.442,4.214.213.648.344,1.322.536,1.977a12.81,12.81,0,0,0,.483,1.406c.383.9.811,1.783,1.2,2.684.194.455.2,1.086.526,1.369.772.673.739,1.671,1.205,2.457.4.674.709.82,1.236.271a47.435,47.435,0,0,0,4.791-5.665c.857-1.232,1.806-2.4,2.689-3.614a13.778,13.778,0,0,0,1.01-1.615c.379-.71.658-1.474,1.057-2.172a6.894,6.894,0,0,0,1.155-2.7,2.831,2.831,0,0,1,.167-.6,15.761,15.761,0,0,0,.607-1.829c.223-1.1.355-2.227.54-3.433.71.193,1.358.38,2.012.545a16.334,16.334,0,0,0,2.944.687,35.479,35.479,0,0,0,9.214-.308c1.221-.248,2.472-.35,3.71-.518a1,1,0,0,0,.141-.023c.949-.273,1.9-.531,2.845-.827.465-.146.907-.364,1.359-.549-.26-.255-.522-.509-.78-.766-.031-.031-.03-.093-.061-.125q-1.77-1.818-3.545-3.633-.955-.975-1.922-1.94c-1.034-1.032-2.074-2.058-3.108-3.09a14.756,14.756,0,0,1-1.062-1.108c-.709-.874-1.382-1.778-2.078-2.664-.559-.712-1.138-1.408-1.691-2.124s-1.078-1.463-1.637-2.178c-.273-.349-.636-.63-.888-.99-.515-.738-.932-1.547-1.48-2.257a18.113,18.113,0,0,1-2.068-2.971c-.157-.317-.358-.612-.541-.916-.622-1.028-1.26-2.047-1.862-3.088-.368-.636-.685-1.3-1.016-1.96-.387-.77-.789-1.535-1.138-2.323-.208-.47-.286-1-.5-1.467-.482-1.068-1.046-2.1-1.512-3.175-.5-1.147-.912-2.329-1.375-3.491a2.474,2.474,0,0,0-3.1-1.755,5.854,5.854,0,0,0-1.123.442c-.846.378-1.671.81-2.536,1.14-.656.251-1.362.37-2.04.564-.477.137-.954.281-1.417.458-.952.365-1.878.81-2.847,1.118-1.12.356-2.274.607-3.416.891a33.6,33.6,0,0,1-3.5.822c-1.567.214-3.155.294-4.738.365a2.156,2.156,0,0,1-2.1-.9,3.226,3.226,0,0,1,.595-.928,23.42,23.42,0,0,1,2.163-1.4c.947-.564,1.915-1.093,2.874-1.638.269-.153.537-.307.808-.457q.947-.521,1.9-1.038c.137-.075.275-.148.417-.212.649-.293,1.3-.582,1.949-.875.344-.156.686-.317,1.029-.476a3.948,3.948,0,0,0,.412-.2,6.889,6.889,0,0,1,1.635-.984,10.877,10.877,0,0,0,2.981-1.806A20.9,20.9,0,0,0,68.3,83.88c.676-.533,1.484-.982,1.706-1.97" transform="translate(0 0)"/>
<path id="Path_534" data-name="Path 534" d="M289.131,546.074c.75-.279,1.383.2,2.05.526.115.056.211.171.329.2a34.875,34.875,0,0,0,8.418.5c.095,0,.19-.011.285-.02,1.62-.157,3.246-.264,4.855-.5a14.41,14.41,0,0,0,2.223-.7c.111-.036.237-.024.351-.055,1-.271,2-.549,3-.818.182-.049.384-.035.56-.1.62-.217,1.227-.475,1.851-.678.465-.151.955-.223,1.423-.366,1.011-.309,2.042-.577,3.014-.981,1.1-.456,2.127-1.064,3.2-1.566.51-.237,1.081-.341,1.591-.577.782-.361,1.533-.787,2.3-1.177.331-.168.671-.318,1.011-.467a2.2,2.2,0,0,1,.278-.052c.277-.078.553-.163.829-.245.04.328.093.654.117.983.154,2.072.31,4.145.448,6.218.11,1.652.173,3.308.3,4.959.1,1.339.282,2.672.385,4.01.06.78-.321,1.148-1.071,1.309a9.81,9.81,0,0,0-1.385.526l-.09.5c-.132-.071-.276-.216-.367-.188-.575.177-1.142.382-1.7.6s-1.107.456-1.661.683c-.348.143-.7.275-1.049.419-.96.4-1.915.807-2.881,1.188-.46.181-.938.318-1.413.454-.657.189-1.317.371-1.981.533-1.024.25-2.058.459-3.077.728-.955.252-1.89.58-2.844.835-.678.181-1.391.242-2.058.449a26.292,26.292,0,0,1-5.14.907c-.48.05-.959.746-1.31,1.237-.424.592-.642,1.333-1.073,1.919-.707.96-1.585,1.8-2.261,2.778a22.346,22.346,0,0,1-2.65,2.934,14.76,14.76,0,0,0-1.344,1.653,1.118,1.118,0,0,0-.143.491,7.872,7.872,0,0,0-.821.641c-1.237,1.3-2.423,2.642-3.7,3.9-1.163,1.144-2.416,2.2-3.632,3.287-.88.789-1.753,1.587-2.659,2.346a.724.724,0,0,1-.621-.033c-.612-.313-1.2-.671-1.794-1.02-.536-.315-1.062-.648-1.6-.962-.913-.535-1.838-1.05-2.745-1.594-.764-.458-1.507-.952-2.268-1.414-.245-.149-.534-.225-.78-.372-1.213-.727-2.41-1.481-3.632-2.193-.464-.271-.979-.455-1.627-.75,1.078-.907,2.106-1.775,3.139-2.638q3.01-2.514,5.813-5.254c.673-.657,1.435-1.26,2.086-1.966.959-1.041,1.931-2.071,2.866-3.133.63-.716,1.234-1.46,1.8-2.228.42-.572.748-1.212,1.138-1.808.439-.671.928-1.311,1.348-1.993s.807-1.417,1.19-2.137.763-1.447,1.111-2.187c.228-.483.38-1,.6-1.492a10.8,10.8,0,0,0,.953-3.608,17.7,17.7,0,0,1,.524-2.442" transform="translate(-190.393 -384.975)"/>
</g>
</svg>
......@@ -3,7 +3,8 @@ Vue.use(VueFormulate, {
locale: "cs",
});
Vue.use(Vue.component("MailtrainFormContainer", {
new Vue({
el: ".mailtrain-form-container",
props: {
url: String,
},
......@@ -13,7 +14,4 @@ Vue.use(Vue.component("MailtrainFormContainer", {
console.log(this, ...data);
},
},
render(createElement) {
return createElement("div", {}, this.$slots.default);
}
}))
});
This diff is collapsed.
{% load wagtailcore_tags %}
{% load static wagtailcore_tags wagtailroutablepage_tags %}
<div class="__js-root">
<ui-app inline-template>
<div class="grid-container mt-20 xl:mt-0 xl:items-center z-10">
<div class="flex flex-row flex-wrap xl:items-center mt-20 xl:mt-0">
<noscript>
<ul class="flex flex-col w-full drop-shadow-lg">
<li class="px-5 py-4 text-center relative z-50 bg-green-400 text-white">
<li class="px-5 py-4 text-center relative bg-green-400 text-white">
<i class="ico--checkmark mr-2"></i>
{% if self.config.require_confirmation %}
{{ self.design.require_confirmation }}
......@@ -13,8 +14,13 @@
{% endif %}
</li>
</ul>
<div>
</noscript>
<div class="mr-5">
{% if self.design.icon %}
<img src="{{ self.design.icon.full_url }}" alt="newsletter_icon" class="newsletter-grid__icon text-7xl xl:text-9xl w-32">
{% else %}
<img src="{% static "shared/img/newsletter.svg" %}" alt="newsletter_icon" class="newsletter-grid__icon text-7xl xl:text-9xl w-32">
{% endif %}
</div>
<div>
<h5 class="font-alt mb-2 text-5xl md:text-6xl xl:text-7xl uppercase">
......@@ -24,31 +30,45 @@
{{ self.design.subtitle }}
</span>
<div class="flex flex-col items-start">
<MailtrainFormContainer url="{% if self.config.force_subscribe %}{% routablepageurl page.root_page 'newsletter' force_subscribe=True %}{% else %}{% routablepageurl page.root_page 'newsletter' %}{% endif %}">
<FormulateForm @submit="onSubmit" #default="{ isLoading, hasErrors }">
{% if page.has_newsletter_form %}
<div url="{% routablepageurl page.root_page 'newsletter' %}" class="mailtrain-form-container">
{% else %}
<div url="{% routablepageurl page 'newsletter' %}" class="mailtrain-form-container">
{% endif %}
<formulate-form @submit="onSubmit" #default="{ isLoading, hasErrors }">
{% csrf_token %}
{% if self.config.send_timezone %}
<FormulateInput
<formulate-input
type="hidden"
name="send_timezone"
value="True"
/>
{% endif %}
{% if self.config.force_subscribe %}
<formulate-input
type="hidden"
name="force_subscribe"
value="True"
/>
{% endif %}
{% if self.config.show_name_input %}
<FormulateInput type="text" name="first_name" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.first_name }}"
<formulate-input type="text" name="first_name" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.first_name }}"
placeholder="{{ self.design.labels.first_name }}" validation="required" error-behavior="value"
label-class="sr-only" />
<FormulateInput type="text" name="last_name" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.last_name }}"
<formulate-input type="text" name="last_name" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.last_name }}"
placeholder="{{ self.design.labels.last_name }}" validation="required" error-behavior="value"
label-class="sr-only" />
{% endif %}
<FormulateInput type="email" name="email" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.email }}"
<formulate-input type="email" name="email" :element-class="() => ['text-input', 'bg-white', 'form-field__control', 'mb-3', 'w-full']" label="{{ self.design.labels.email }}"
placeholder="{{ self.design.labels.email }}" validation="required|email" error-behavior="value"
label-class="sr-only" />
<div class="checkbox form-field__control flex items-center mb-3">
<FormulateInput type="checkbox" label="{% include_block self.design.consent %}" label-class="text-xs font-alt font-light" validation="required" error-behavior="value" />
<formulate-input id="consent_checkbox" type="checkbox" :element-class="() => []" validation="required" error-behavior="value" />
<label for="consent_checkbox" class="text-xs font-alt font-light">
{% include_block self.design.consent %}
</label>
</div>
<FormulateErrors />
<formulate-errors />
<button type="submit" :disabled="isLoading || hasErrors" class="btn btn--black btn--to-yellow-500 btn--hoveractive uppercase">
<span class="btn__body-wrap">
<span v-html="isLoading ? 'Odesílám...' : '{{ self.design.button }}'" class="btn__body text-lg lg:text-base">
......@@ -56,8 +76,8 @@
</span>
</span>
</button>
</FormulateForm>
</MailtrainFormContainer>
</formulate-form>
</div>
</div>
</div>
</div>
......
......@@ -25,7 +25,7 @@ from wagtail.models import Page
from wagtailmetadata.models import MetadataPageMixin
from calendar_utils.models import CalendarMixin
from shared.blocks import ChartBlock, FooterLinksBlock
from shared.blocks import ChartBlock, NewsletterSubscriptionBlock
from shared.const import RICH_TEXT_DEFAULT_FEATURES
from shared.models import (
ArticleMixin,
......@@ -312,7 +312,7 @@ class UniwebHomePage(
### FIELDS
content = StreamField(
CONTENT_STREAM_BLOCKS,
CONTENT_STREAM_BLOCKS + [("newsletter", NewsletterSubscriptionBlock())],
verbose_name="obsah stránky",
blank=True,
use_json_field=True,
......@@ -421,12 +421,16 @@ class UniwebHomePage(
class UniwebFlexiblePage(
Page, ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin
Page,
ExtendedMetadataPageMixin,
SubpageMixin,
MetadataPageMixin,
NewsletterFormMixin,
):
### FIELDS
content = StreamField(
CONTENT_STREAM_BLOCKS,
CONTENT_STREAM_BLOCKS + [("newsletter", NewsletterSubscriptionBlock())],
verbose_name="obsah stránky",
blank=True,
use_json_field=True,
......@@ -440,7 +444,7 @@ class UniwebFlexiblePage(
FieldPanel("content"),
]
settings_panels = []
settings_panels = NewsletterFormMixin.settings_panels
### RELATIONS
......
......@@ -20,6 +20,7 @@
<link href="https://styleguide.pirati.cz/2.11.x/css/styles.css" rel="stylesheet" media="all" />
<link href="https://styleguide.pirati.cz/2.11.x/css/pattern-scaffolding.css" rel="stylesheet" media="all" />
<link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet">
<link rel="stylesheet" href="{% static "shared/vendor/bootstrap-4.4.1/css/bootstrap.min.css" %}">
<style type="text/css">
.head-alt-md, .head-alt-lg {
......@@ -155,5 +156,8 @@
<script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script>
<script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script>
<script src="{% static "shared/vendor/fancybox/jquery.fancybox.min.js" %}"></script>
<script src="{% static "shared/vendor/vue-formulate-2.5.3/js/formulate.min.js" %}"></script>
<script src="{% static "shared/vendor/vue-formulate-i18n-1.16.0/js/cs.min.js" %}"></script>
<script src="{% static "shared/js/vue-formulate-helper.js" %}"></script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment