Skip to content
Snippets Groups Projects
Commit 882f024b authored by Alexa Valentová's avatar Alexa Valentová
Browse files

add nakopneme calculator

parent 402d818c
Branches
No related tags found
2 merge requests!1369add nakopneme calculator,!1368add nakopneme calculator
Pipeline #21210 passed
Showing
with 1340 additions and 37 deletions
from wagtail.blocks import CharBlock, ListBlock, RichTextBlock, StructBlock, URLBlock
from django.template.defaultfilters import slugify
from wagtail.blocks import (
CharBlock,
IntegerBlock,
ListBlock,
RichTextBlock,
StructBlock,
URLBlock,
)
from wagtail.images.blocks import ImageChooserBlock
......@@ -145,3 +153,41 @@ class NakopnemeSquareCardBlock(StructBlock):
template = (
"styleguide2/includes/molecules/boxes/nakopneme/square_flip_card_box.html"
)
class CalculatorItemBlock(StructBlock):
heading = CharBlock(label="Nadpis")
text = CharBlock(label="Text")
value = IntegerBlock(label="Hodnota (Kč)")
slug = CharBlock(label="Slug (nevyplňovat)")
def get_prep_value(self, value):
value = super().get_prep_value(value)
value["slug"] = slugify(value["heading"])
return value
class Meta:
label = "Objekt v kalkulačce"
template = "styleguide2/includes/organisms/nakopneme/calculator_item.html"
class CalculatorPayableBlock(StructBlock):
def get_prep_value(self, value):
value = super().get_prep_value(value)
value["slug"] = slugify(value["form_other"])
return value
slug = CharBlock(label="Slug (nevyplňovat)")
form_1 = CharBlock(label="Tvar slova (1)")
form_2 = CharBlock(label="Tvar slova (2)")
form_3 = CharBlock(label="Tvar slova (3)")
form_4 = CharBlock(label="Tvar slova (4)")
form_5 = CharBlock(label="Tvar slova (5)")
form_other = CharBlock(label="Tvar slova (6+)")
value = IntegerBlock(label="Hodnota (Kč)")
class Meta:
label = "Věc, za kterou by se dalo zaplatit"
......@@ -4,15 +4,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('nakopneme', '0026_nakopnemeformpage_nakopnemeformpageformfield'),
("nakopneme", "0026_nakopnemeformpage_nakopnemeformpageformfield"),
]
operations = [
migrations.AddField(
model_name='nakopnemeformpage',
name='ecomail_newsletter_list_tags',
field=models.CharField(default='nakopneme-petice', max_length=128, verbose_name='Ecomail NL tagy'),
model_name="nakopnemeformpage",
name="ecomail_newsletter_list_tags",
field=models.CharField(
default="nakopneme-petice",
max_length=128,
verbose_name="Ecomail NL tagy",
),
),
]
# Generated by Django 5.0.7 on 2025-06-03 17:31
import django.db.models.deletion
import wagtail.fields
import wagtailmetadata.models
from django.db import migrations, models
import shared.models.main
class Migration(migrations.Migration):
dependencies = [
("nakopneme", "0027_nakopnemeformpage_ecomail_newsletter_list_tags"),
("wagtailcore", "0094_alter_page_locale"),
("wagtailimages", "0027_image_description"),
]
operations = [
migrations.CreateModel(
name="NakopnemeCalculatorPage",
fields=[
(
"page_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="wagtailcore.page",
),
),
(
"subclaim",
models.CharField(blank=True, null=True, verbose_name="Subclaim"),
),
(
"under_subclaim_text",
wagtail.fields.StreamField(
[
("text", 0),
("advanced_text", 4),
("two_columns_text", 7),
("headline", 12),
("headline_with_picture", 15),
("picture_list", 19),
("flip_cards", 30),
("table", 31),
("popout_table", 32),
("gallery", 35),
("figure", 38),
("card", 63),
("two_columns", 73),
("three_columns", 75),
("youtube", 76),
("map_point", 53),
("map_collection", 60),
("button", 68),
("button_group", 70),
("popout_point", 79),
],
blank=True,
block_lookup={
0: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": [
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
"group": "1. Text",
"label": "Textový editor",
"template": "styleguide2/includes/atoms/text/prose_richtext.html",
},
),
1: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("left", "vlevo"),
("center", "uprostřed"),
("right", "vpravo"),
],
"label": "zarovnání",
},
),
2: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("black_on_white", "černá na bílé"),
("black_on_yellow", "černá na žluté"),
("white_on_black", "bílá na černé"),
("white_on_blue", "bílá na modré"),
("white_on_cyan", "bílá na tyrkysové"),
("white_on_violet", "bílá na fialové"),
],
"label": "barva",
},
),
3: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": [
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
"group": "1. Text",
"label": "Textový editor",
},
),
4: (
"wagtail.blocks.StructBlock",
[[("align", 1), ("color", 2), ("text", 3)]],
{},
),
5: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": [
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
"label": "levý sloupec",
},
),
6: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": [
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
"label": "pravý sloupec",
},
),
7: (
"wagtail.blocks.StructBlock",
[[("left_text", 5), ("right_text", 6)]],
{},
),
8: (
"wagtail.blocks.CharBlock",
(),
{
"label": "Nadpis",
"max_length": 300,
"required": True,
},
),
9: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("h1", "H1"),
("h2", "H2"),
("h3", "H3"),
("h4", "H4"),
("h5", "H5"),
("h6", "H6"),
],
"help_text": "Čím nižší číslo, tím vyšší úroveň.",
"label": "Úroveň nadpisu",
},
),
10: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("head-alt-xl", "Velký, Bebas Neue - 6XL"),
("head-alt-lg", "Střední, Bebas Neue - 4XL"),
(
"head-alt-md",
"Základní velikost - Roboto - MD",
),
("head-alt-sm", "Malý - Roboto - SM"),
("head-alt-xs", "Extra malý - Roboto - XS"),
],
"help_text": "Náhled si prohlédněte na https://styleguide2.pirati.cz/pattern/patterns/atoms/text/headings.html.",
"label": "Velikost",
},
),
11: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("auto", "Automaticky"),
("center", "Na střed"),
],
"label": "Zarovnání",
},
),
12: (
"wagtail.blocks.StructBlock",
[
[
("headline", 8),
("tag", 9),
("style", 10),
("align", 11),
]
],
{},
),
13: ("wagtail.blocks.CharBlock", (), {"label": "nadpis"}),
14: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{
"help_text": "rozměr na výšku 75px nebo více (obrázek bude zmenšen na výšku 75px)",
"label": "obrázek",
},
),
15: (
"wagtail.blocks.StructBlock",
[[("color", 2), ("title", 13), ("picture", 14)]],
{},
),
16: (
"wagtail.blocks.RichTextBlock",
(),
{
"features": [
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
"embed",
],
"label": "Odstavec",
},
),
17: (
"wagtail.blocks.ListBlock",
(16,),
{"label": "Odstavce"},
),
18: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{
"help_text": "Rozměr 30x30px nebo více (obrázek bude zmenšen na 30x30px)",
"label": "Obrázek",
},
),
19: (
"wagtail.blocks.StructBlock",
[[("color", 2), ("items", 17), ("picture", 18)]],
{},
),
20: (
"wagtail.blocks.CharBlock",
(),
{
"default": "FEC900",
"help_text": "Kód barvy lze vytvořit např. <a href='https://mdn.github.io/css-examples/tools/color-picker/' target='_blank'>zde</a>.",
"label": "Barva pozadí",
},
),
21: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{
"help_text": "Nahrazuje pozadí. Nelze vybrat obě najednou.",
"label": "Obrázek",
"required": False,
},
),
22: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{
"help_text": "Nahrazuje obrázek. Nelze vybrat obě najednou.",
"label": "Pozadí",
"required": False,
},
),
23: (
"wagtail.blocks.TextBlock",
(),
{
"help_text": "Řádkování je manuální.",
"label": "Nadpis",
},
),
24: (
"wagtail.blocks.CharBlock",
(),
{
"default": "000000",
"help_text": "Kód barvy lze vytvořit např. <a href='https://mdn.github.io/css-examples/tools/color-picker/' target='_blank'>zde</a>.",
"label": "Barva textu",
},
),
25: (
"wagtail.blocks.RichTextBlock",
(),
{"label": "Obsah"},
),
26: (
"wagtail.blocks.CharBlock",
(),
{
"help_text": "Pokud není vyplněn, tlačítko se neukáže.",
"label": "Nadpis tlačítka",
"required": False,
},
),
27: (
"wagtail.blocks.CharBlock",
(),
{"label": "Odkaz tlačítka", "required": False},
),
28: (
"wagtail.blocks.StructBlock",
[
[
("bg_color", 20),
("image", 21),
("background", 22),
("title", 23),
("title_color", 24),
("content", 25),
("button_text", 26),
("button_url", 27),
]
],
{"label": "Karta"},
),
29: ("wagtail.blocks.ListBlock", (28,), {"label": "Karty"}),
30: ("wagtail.blocks.StructBlock", [[("cards", 29)]], {}),
31: (
"wagtail.contrib.table_block.blocks.TableBlock",
(),
{
"group": "3. Ostatní",
"label": "Tabulka",
"template": "styleguide2/includes/atoms/table/table.html",
},
),
32: (
"wagtail.contrib.table_block.blocks.TableBlock",
(),
{
"group": "3. Ostatní",
"label": "Rozbalovací tabulka",
"template": "styleguide2/includes/atoms/table/popout_table.html",
},
),
33: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"label": "obrázek", "required": True},
),
34: (
"wagtail.blocks.ListBlock",
(33,),
{
"group": "3. Ostatní",
"icon": "image",
"label": "Galerie",
},
),
35: (
"wagtail.blocks.StructBlock",
[[("gallery_items", 34)]],
{"label": "Galerie"},
),
36: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"label": "Obrázek", "required": True},
),
37: (
"wagtail.blocks.TextBlock",
(),
{"label": "Popisek", "required": False},
),
38: (
"wagtail.blocks.StructBlock",
[[("img", 36), ("caption", 37)]],
{},
),
39: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{"label": "Obrázek", "required": False},
),
40: (
"wagtail.blocks.TextBlock",
(),
{"label": "Titulek", "required": False},
),
41: (
"wagtail.images.blocks.ImageChooserBlock",
(),
{
"help_text": "Není třeba vyplňovat, náhled bude dohledán automaticky.",
"label": "Náhled videa (automatické pole)",
"required": False,
},
),
42: (
"wagtail.blocks.URLBlock",
(),
{
"help_text": "Odkaz na YouTube video bude automaticky zkonvertován na ID videa a NEBUDE uložen.",
"label": "Odkaz na video",
"required": False,
},
),
43: (
"wagtail.blocks.CharBlock",
(),
{
"help_text": "Není třeba vyplňovat, bude automaticky načteno z odkazu.",
"label": "ID videa (automatické pole)",
"required": False,
},
),
44: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"help_text": "Pokud toto pole není zaškrtlé, video bude užší než text okolo.",
"label": "Zabírá maximální šířku povolenou pro text?",
"required": False,
},
),
45: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": False,
"help_text": "Automaticky spustí video bez zvuku. Pozor, některé prohlížeče blokují i automatické přehrávání videí bez zvuku.",
"label": "Spustit video automaticky?",
"required": False,
},
),
46: (
"wagtail.blocks.StructBlock",
[
[
("poster_image", 41),
("video_url", 42),
("video_id", 43),
("is_full_width", 44),
("autoplay", 45),
]
],
{},
),
47: (
"wagtail.blocks.DecimalBlock",
(),
{
"help_text": "Např. 50.04075",
"label": "Zeměpisná šířka",
},
),
48: (
"wagtail.blocks.DecimalBlock",
(),
{
"help_text": "Např. 15.77659",
"label": "Zeměpisná délka",
},
),
49: (
"wagtail.blocks.CharBlock",
(),
{
"default": "000000",
"help_text": "Zadejte barvu pomocí HEX notace (bez # na začátku).",
"label": "Barva špendlíku (HEX)",
},
),
50: (
"wagtail.blocks.IntegerBlock",
(),
{
"default": 15,
"label": "Výchozí zoom",
"max_value": 18,
"min_value": 1,
},
),
51: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("osm-mapnik", "OSM Mapnik"),
("stadia-osm-bright", "Stadia OSM Bright"),
("stadia-outdoors", "Stadia Outdoors"),
("mapbox-streets", "Mapbox Streets"),
("mapbox-outdoors", "Mapbox Outdoors"),
("mapbox-light", "Mapbox Light"),
("mapbox-dark", "Mapbox Dark"),
("mapbox-satellite", "Mapbox Satellite"),
("mapbox-pirate", "Mapbox Pirate Theme"),
],
"label": "Styl",
},
),
52: (
"wagtail.blocks.IntegerBlock",
(),
{
"label": "Výška v px",
"max_value": 1000,
"min_value": 100,
},
),
53: (
"wagtail.blocks.StructBlock",
[
[
("lat", 47),
("lon", 48),
("hex_color", 49),
("zoom", 50),
("style", 51),
("height", 52),
]
],
{"label": "Špendlík na mapě"},
),
54: (
"wagtail.blocks.CharBlock",
(),
{"label": "Titulek", "required": True},
),
55: (
"wagtail.blocks.TextBlock",
(),
{
"help_text": "Vložte surový GeoJSON objekt typu 'Feature'. Vyrobit jej můžete např. pomocí online služby geojson.io. Pokud u objektu poskytnete properties 'title' a 'description', zobrazí se jak na mapě, tak i v detailu.",
"label": "Geodata",
"required": True,
},
),
56: (
"wagtail.blocks.URLBlock",
(),
{"label": "Odkaz", "required": False},
),
57: (
"wagtail.blocks.CharBlock",
(),
{
"default": "000000",
"help_text": "Zadejte barvu pomocí HEX notace (bez # na začátku).",
"label": "Barva (HEX)",
},
),
58: (
"wagtail.blocks.StructBlock",
[
[
("title", 54),
("description", 37),
("geojson", 55),
("image", 39),
("link", 56),
("hex_color", 57),
]
],
{"required": True},
),
59: (
"wagtail.blocks.ListBlock",
(58,),
{"label": "Součásti"},
),
60: (
"wagtail.blocks.StructBlock",
[
[
("features", 59),
("zoom", 50),
("style", 51),
("height", 52),
]
],
{"label": "Mapová kolekce"},
),
61: (
"wagtail.blocks.StreamBlock",
[
[
("text", 3),
("table", 31),
("figure", 38),
("youtube", 46),
("map_point", 53),
("map_collection", 60),
]
],
{"label": "Obsah", "required": False},
),
62: (
"wagtail.blocks.PageChooserBlock",
(),
{"label": "Stránka", "required": False},
),
63: (
"wagtail.blocks.StructBlock",
[
[
("img", 39),
("headline", 40),
("content", 61),
("page", 62),
("link", 56),
]
],
{},
),
64: (
"wagtail.blocks.CharBlock",
(),
{
"label": "Titulek",
"max_length": 128,
"required": True,
},
),
65: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("black", "Černá"),
("white", "Bílá"),
("pirati-yellow", "Žlutá"),
("grey-125", "Světle šedá"),
("blue-300", "Modrá"),
("cyan-200", "Tyrkysová"),
("green-400", "Zelená"),
("violet-400", "Vínová"),
("red-600", "Červená"),
],
"label": "Barva",
},
),
66: (
"wagtail.blocks.BooleanBlock",
(),
{
"default": True,
"help_text": "Pokud je zapnuto, tlačítko při najetí kurzorem ukáže žlutou šipku.",
"label": "Animovat na hover",
"required": False,
},
),
67: (
"wagtail.blocks.ChoiceBlock",
[],
{
"choices": [
("normal", "Normální"),
("large", "Velká"),
("huge", "Masivní"),
],
"label": "Velikost tlačítka",
},
),
68: (
"wagtail.blocks.StructBlock",
[
[
("title", 64),
("color", 65),
("hoveractive", 66),
("page", 62),
("link", 56),
("align", 11),
("size", 67),
]
],
{},
),
69: (
"wagtail.blocks.ListBlock",
(68,),
{"label": "Tlačítka"},
),
70: ("wagtail.blocks.StructBlock", [[("buttons", 69)]], {}),
71: (
"wagtail.blocks.StreamBlock",
[
[
("text", 3),
("table", 31),
("card", 63),
("figure", 38),
("youtube", 46),
("map_point", 53),
("map_collection", 60),
("button", 68),
("button_group", 70),
]
],
{"label": "Obsah levého sloupce", "required": True},
),
72: (
"wagtail.blocks.StreamBlock",
[
[
("text", 3),
("table", 31),
("card", 63),
("figure", 38),
("youtube", 46),
("map_point", 53),
("map_collection", 60),
("button", 68),
("button_group", 70),
]
],
{"label": "Obsah pravého sloupce", "required": True},
),
73: (
"wagtail.blocks.StructBlock",
[
[
("left_column_content", 71),
("right_column_content", 72),
]
],
{},
),
74: (
"wagtail.blocks.StreamBlock",
[
[
("text", 3),
("table", 31),
("card", 63),
("figure", 38),
("youtube", 46),
("map_point", 53),
("map_collection", 60),
("button", 68),
("button_group", 70),
]
],
{
"label": "Obsah prostředního sloupce",
"required": True,
},
),
75: (
"wagtail.blocks.StructBlock",
[
[
("left_column_content", 71),
("middle_column_content", 74),
("right_column_content", 72),
]
],
{},
),
76: (
"wagtail.blocks.StructBlock",
[
[
("poster_image", 41),
("video_url", 42),
("video_id", 43),
("is_full_width", 44),
("autoplay", 45),
]
],
{"label": "YouTube video"},
),
77: (
"wagtail.blocks.CharBlock",
(),
{"label": "Název", "required": True},
),
78: (
"wagtail.blocks.StreamBlock",
[[("text", 0), ("headline", 12), ("table", 31)]],
{"label": "Obsah"},
),
79: (
"wagtail.blocks.StructBlock",
[[("name", 77), ("content", 78)]],
{},
),
},
verbose_name="Obsah pod subclaimem",
),
),
(
"above_money_text",
models.CharField(
default="Sečteno a rozkradeno",
max_length=32,
verbose_name="Text nad součtem",
),
),
(
"after_count_text",
wagtail.fields.RichTextField(
blank=True,
null=True,
verbose_name='Obsah pod "Za to jsme mohli pořídit"',
),
),
(
"button_text",
models.CharField(
default="Jak na korupci",
max_length=32,
verbose_name="Nadpis tlačítka na zobrazení programu",
),
),
(
"button_url",
models.URLField(
default="https://nakopnemeto.pirati.cz/program/",
max_length=64,
verbose_name="URL tlačítka na zobrazení programu",
),
),
(
"calc_blocks",
wagtail.fields.StreamField(
[("calculator_item", 3)],
blank=True,
block_lookup={
0: ("wagtail.blocks.CharBlock", (), {"label": "Nadpis"}),
1: ("wagtail.blocks.CharBlock", (), {"label": "Text"}),
2: (
"wagtail.blocks.IntegerBlock",
(),
{"label": "Hodnota (Kč)"},
),
3: (
"wagtail.blocks.StructBlock",
[[("heading", 0), ("text", 1), ("value", 2)]],
{},
),
},
verbose_name="Objekty v kalkulačce",
),
),
(
"search_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
verbose_name="Search image",
),
),
],
options={
"verbose_name": "Kalkulačka",
},
bases=(
shared.models.main.SubpageMixin,
wagtailmetadata.models.WagtailImageMetadataMixin,
"wagtailcore.page",
models.Model,
),
),
]
# Generated by Django 5.0.7 on 2025-06-03 17:38
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("nakopneme", "0028_nakopnemecalculatorpage"),
]
operations = [
migrations.RenameField(
model_name="nakopnemecalculatorpage",
old_name="under_subclaim_text",
new_name="under_subclaim_content",
),
]
# Generated by Django 5.0.7 on 2025-06-03 18:11
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
(
"nakopneme",
"0029_rename_under_subclaim_text_nakopnemecalculatorpage_under_subclaim_content",
),
]
operations = [
migrations.AddField(
model_name="nakopnemecalculatorpage",
name="payable_blocks",
field=wagtail.fields.StreamField(
[("calculator_payable", 7)],
blank=True,
block_lookup={
0: ("wagtail.blocks.CharBlock", ("Tvar slova (1)",), {}),
1: ("wagtail.blocks.CharBlock", ("Tvar slova (2)",), {}),
2: ("wagtail.blocks.CharBlock", ("Tvar slova (3)",), {}),
3: ("wagtail.blocks.CharBlock", ("Tvar slova (4)",), {}),
4: ("wagtail.blocks.CharBlock", ("Tvar slova (5)",), {}),
5: ("wagtail.blocks.CharBlock", ("Tvar slova (6+)",), {}),
6: ("wagtail.blocks.IntegerBlock", (), {"label": "Hodnota (Kč)"}),
7: (
"wagtail.blocks.StructBlock",
[
[
("form_1", 0),
("form_2", 1),
("form_3", 2),
("form_4", 3),
("form_5", 4),
("form_other", 5),
("value", 6),
]
],
{},
),
},
verbose_name="Za co by se dalo zaplatit",
),
),
]
......@@ -8,7 +8,7 @@ from wagtail.admin.panels import FieldPanel, InlinePanel, ObjectList, TabbedInte
from wagtail.contrib.forms.models import AbstractForm, AbstractFormField
from wagtail.contrib.forms.panels import FormSubmissionsPanel
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.fields import StreamField
from wagtail.fields import RichTextField, StreamField
from wagtail.models import Page
from wagtailmetadata.models import MetadataPageMixin
......@@ -106,6 +106,7 @@ class NakopnemeHomePage(MainHomePageMixin, EcomailNewsletterMixin, RoutablePageM
"nakopneme.NakopnemeHelpUsPage",
"nakopneme.NakopnemeContactPage",
"nakopneme.NakopnemeFormPage",
"nakopneme.NakopnemeCalculatorPage",
]
### PANELS
......@@ -562,3 +563,82 @@ class NakopnemeFormPage(
form = super().get_form_class()
form.base_fields["captcha"] = CaptchaField(label="opište písmena z obrázku")
return form
class NakopnemeCalculatorPage(
ContextMixin,
ExtendedMetadataPageMixin,
SubpageMixin,
MetadataPageMixin,
PageInMenuMixin,
Page,
):
subclaim = models.CharField(verbose_name="Subclaim", blank=True, null=True)
under_subclaim_content = StreamField(
shared_blocks.DEFAULT_CONTENT_BLOCKS,
verbose_name="Obsah pod subclaimem",
blank=True,
use_json_field=True,
)
above_money_text = models.CharField(
verbose_name="Text nad součtem",
default="Sečteno a rozkradeno",
max_length=32,
)
after_count_text = RichTextField(
verbose_name='Obsah pod "Za to jsme mohli pořídit"',
blank=True,
null=True,
)
button_text = models.CharField(
verbose_name="Nadpis tlačítka na zobrazení programu",
default="Jak na korupci",
max_length=32,
)
button_url = models.URLField(
verbose_name="URL tlačítka na zobrazení programu",
max_length=64,
default="https://nakopnemeto.pirati.cz/program/",
)
calc_blocks = StreamField(
[
("calculator_item", blocks.CalculatorItemBlock()),
],
verbose_name="Objekty v kalkulačce",
blank=True,
use_json_field=True,
)
payable_blocks = StreamField(
[
("calculator_payable", blocks.CalculatorPayableBlock()),
],
verbose_name="Za co by se dalo zaplatit",
blank=True,
use_json_field=True,
)
parent_page_types = [
"nakopneme.NakopnemeHomePage",
]
subpage_types = []
content_panels = Page.content_panels + [
FieldPanel("subclaim"),
FieldPanel("under_subclaim_content"),
FieldPanel("calc_blocks"),
FieldPanel("payable_blocks"),
FieldPanel("above_money_text"),
FieldPanel("after_count_text"),
FieldPanel("button_text"),
FieldPanel("button_url"),
]
class Meta:
verbose_name = "Kalkulačka"
{% extends "styleguide2/simple_page.html" %}
{% load wagtailcore_tags %}
{% block header %}
{% include "styleguide2/includes/organisms/header/nakopneme/simple_header.html" with title=page.title %}
{% endblock %}
{% block footer %}
{% include 'styleguide2/includes/organisms/layout/footer.html' with page=main_context.page %}
{% endblock %}
{% block inner_content %}
<div class="container--wide mb-8">
<h2 class="head-10xl mb-8">
{{ page.subclaim }}
</h2>
<div>
{% for block in page.under_subclaim_content %}
{% include_block block %}
{% endfor %}
</div>
<div class="my-8 flex flex-col gap-4">
{% for block in page.calc_blocks %}
{% include_block block %}
{% endfor %}
</div>
<h2 class="text-center head-9xl mb-4">{{ page.above_money_text }}</h2>
<div class="flex justify-center">
<div class="bg-pirati-yellow p-5 head-8xl font-alt justify-center flex min-w-96">
<div id="total" data-value="0">0 Kč</div>
</div>
</div>
<div class="mt-8 text-3xl lg:text-4xl max-w-3xl mx-auto hidden min-h-40" id="buyable-things-wrapper">
<span>Za to jsme mohli pořídit</span>
<span id="buyable-things" class="font-bold"></span><span>.</span>
</div>
<div class="prose prose-black mt-8 [&_p]:text-lg mx-auto">
{{ page.after_count_text|richtext }}
</div>
<div class="flex justify-center mt-8">
{% include 'styleguide2/includes/atoms/buttons/round_button.html' with classes="bg-black text-white text-xl" text=page.button_text url=page.button_url %}
</div>
</div>
<script>
const thingPrices = {
{% for payable in page.payable_blocks %}
"{{ payable.value.slug }}": {
value: {{ payable.value.value }},
form2: "{{ payable.value.form_2 }}",
form1: "{{ payable.value.form_1 }}",
form3: "{{ payable.value.form_3 }}",
form4: "{{ payable.value.form_4 }}",
form5: "{{ payable.value.form_5 }}",
formOther: "{{ payable.value.form_other }}"
}{% if not forloop.last %},{% endif %}
{% endfor %}
};
const buyWrapper = document.getElementById("buyable-things-wrapper");
const total = document.getElementById("total");
for (const element of document.getElementsByClassName("_calculator_item")) {
element.addEventListener(
"change",
(event) => {
let currentValue = Number(total.dataset.value);
let targetValue = Number(event.currentTarget.dataset.monetaryValue);
let finalValue = 0;
if (event.currentTarget.checked) {
finalValue = currentValue + targetValue;
} else {
finalValue = currentValue - targetValue;
}
total.dataset.value = finalValue;
let buyableThingsText = "";
let position = 0;
const thingPricesLength = Object.keys(thingPrices).length;
let foundAnything = false;
for (let [key, content] of Object.entries(thingPrices)) {
if (finalValue / content.value > 1) {
const actualCount = Math.floor(finalValue / content.value);
if (position + 1 == thingPricesLength) {
buyableThingsText += ", nebo ";
} else if (position != 0 && buyableThingsText !== "") {
buyableThingsText += ", nebo ";
}
buyableThingsText += `${actualCount} `
let usedForm = "";
switch (actualCount) {
case 1:
usedForm = content.form1;
break;
case 2:
usedForm = content.form2;
break;
case 3:
usedForm = content.form3;
break;
case 4:
usedForm = content.form4;
break;
case 5:
usedForm = content.form5;
break;
default:
usedForm = content.formOther;
break;
}
buyableThingsText += usedForm;
foundAnything = true;
}
position++;
}
if (!foundAnything) {
document.getElementById("buyable-things-wrapper").classList.add("hidden");
total.innerHTML = `${finalValue.toLocaleString()} Kč`;
return;
}
if (document.getElementById("buyable-things-wrapper").classList.contains("hidden")) {
document.getElementById("buyable-things").innerHTML = buyableThingsText;
document.getElementById("buyable-things-wrapper").classList.remove("hidden");
} else {
buyWrapper.animate([ { opacity: [0] } ], { duration: 250 });
setTimeout(() => {
document.getElementById("buyable-things").innerHTML = buyableThingsText;
buyWrapper.animate([ { opacity: [1] } ], { duration: 250 });
}, 250);
}
total.animate([ { opacity: [0] } ], { duration: 250 });
setTimeout(() => {
total.animate([ { opacity: [1] } ], { duration: 250 });
total.innerHTML = `${finalValue.toLocaleString()} Kč`;
});
}
)
}
</script>
{% endblock %}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
<label for="{{ self.slug }}" class="flex justify-between items-center gap-6 p-6 bg-grey-150 hover:bg-grey-175 duration-150 group cursor-pointer">
<div class="flex flex-col gap-1">
<h3 class="font-alt text-4xl">{{ self.heading }}</h3>
<div class="text-lg">{{ self.text }}</div>
</div>
<div class="form__checkbox">
<input
id="{{ self.slug }}"
name="{{ self.slug }}"
data-monetary-value="{{ self.value }}"
type="checkbox"
class="_calculator_item !w-10 !h-10 group"
autocomplete="off"
>
</div>
</label>
context:
heading: 'Podívejte se na celý program'
subheading: 'Poslat celý program na email'
image_url: '../../../../../../../static/images/nakopneme/politicians.png'
context:
leader_id: 'ustecky'
image_url: '../../../../../static/images/nakopneme/olga.jpg'
header: 'Olga Richterová'
subheader: 'Ministr průmyslu a dopravy'
content: 'Etiam egestas wisi a erat. Integer lacinia. Sed ac dolor sit amet purus malesuada congue. Pellentesque sapien. Nulla non lectus sed nisl molestie malesuada. Fusce tellus. Sed ac dolor sit amet purus malesuada congue. Mauris suscipit, ligula sit amet pharetra semper, nibh ante cursus purus, vel sagittis velit mauris vel metus. Aenean fermentum risus id tortor. Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus. Integer vulputate sem a nibh rutrum consequat. Cras pede libero, dapibus nec.'
profile_url: '#'
social_links:
-
icon: 'facebook'
url: 'https://facebook.com'
-
icon: 'youtube'
url: 'https://facebook.com'
-
icon: 'instagram'
url: 'https://facebook.com'
context:
leader_id: 'ustecky'
leader_title: 'Ústecký kraj'
context:
heading: 'Naši lídři a lídryně'
context:
heading: 'Nakopněte to s námi'
quote_content: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ante orci, molestie vitae vehicula venenatis, tincidunt ac pede. Nam sed tellus id magna elementum tincidunt. Nullam faucibus mi quis velit. Pellentesque ipsum. Phasellus et lorem id felis nonummy placerat. Aenean placerat. Sed elit dui, pellentesque a, faucibus vel, interdum nec, diam. '
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment