From 67fd30826dfcdfccbdd98ff5232b02843fb1528b Mon Sep 17 00:00:00 2001
From: Dan Nepejchal <dan.nepejchal@european-pirateparty.eu>
Date: Mon, 18 Jan 2021 13:04:41 +0100
Subject: [PATCH] Regulace konopi: - text 3 columns block

---
 .../migrations/0008_auto_20210118_1259.py     | 218 ++++++++++++++++++
 regulace_konopi/models.py                     |  29 ++-
 .../templates/regulace_konopi/base.html       |   4 +-
 .../regulace_konopi/snippet_sections.html     |  10 +
 4 files changed, 256 insertions(+), 5 deletions(-)
 create mode 100644 regulace_konopi/migrations/0008_auto_20210118_1259.py

diff --git a/regulace_konopi/migrations/0008_auto_20210118_1259.py b/regulace_konopi/migrations/0008_auto_20210118_1259.py
new file mode 100644
index 00000000..1fd336bf
--- /dev/null
+++ b/regulace_konopi/migrations/0008_auto_20210118_1259.py
@@ -0,0 +1,218 @@
+# Generated by Django 3.1.1 on 2021-01-18 11:59
+
+import wagtail.core.blocks
+import wagtail.core.fields
+import wagtail.images.blocks
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("regulace_konopi", "0007_auto_20201214_1346"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="regkonsubpage",
+            name="content",
+            field=wagtail.core.fields.StreamField(
+                [
+                    (
+                        "title",
+                        wagtail.core.blocks.CharBlock(icon="title", label="nadpis"),
+                    ),
+                    (
+                        "text",
+                        wagtail.core.blocks.RichTextBlock(
+                            features=[
+                                "h2",
+                                "h3",
+                                "h4",
+                                "h5",
+                                "bold",
+                                "italic",
+                                "ol",
+                                "ul",
+                                "hr",
+                                "link",
+                                "document-link",
+                                "image",
+                                "superscript",
+                                "subscript",
+                                "strikethrough",
+                                "blockquote",
+                            ],
+                            label="text",
+                        ),
+                    ),
+                    (
+                        "text_centered",
+                        wagtail.core.blocks.RichTextBlock(
+                            features=[
+                                "h2",
+                                "h3",
+                                "h4",
+                                "h5",
+                                "bold",
+                                "italic",
+                                "ol",
+                                "ul",
+                                "hr",
+                                "link",
+                                "document-link",
+                                "image",
+                                "superscript",
+                                "subscript",
+                                "strikethrough",
+                                "blockquote",
+                            ],
+                            label="text-center",
+                        ),
+                    ),
+                    (
+                        "text_justify",
+                        wagtail.core.blocks.RichTextBlock(
+                            features=[
+                                "h2",
+                                "h3",
+                                "h4",
+                                "h5",
+                                "bold",
+                                "italic",
+                                "ol",
+                                "ul",
+                                "hr",
+                                "link",
+                                "document-link",
+                                "image",
+                                "superscript",
+                                "subscript",
+                                "strikethrough",
+                                "blockquote",
+                            ],
+                            label="text-justify",
+                        ),
+                    ),
+                    (
+                        "carousel",
+                        wagtail.core.blocks.ListBlock(
+                            wagtail.images.blocks.ImageChooserBlock(label="obrázek"),
+                            icon="image",
+                            label="carousel",
+                        ),
+                    ),
+                    (
+                        "carousel_text",
+                        wagtail.core.blocks.ListBlock(
+                            wagtail.core.blocks.RichTextBlock(
+                                features=[
+                                    "h2",
+                                    "h3",
+                                    "h4",
+                                    "h5",
+                                    "bold",
+                                    "italic",
+                                    "ol",
+                                    "ul",
+                                    "hr",
+                                    "link",
+                                    "document-link",
+                                    "image",
+                                    "superscript",
+                                    "subscript",
+                                    "strikethrough",
+                                    "blockquote",
+                                ]
+                            ),
+                            icon="image",
+                            label="carousel-text",
+                        ),
+                    ),
+                    (
+                        "FAQ",
+                        wagtail.core.blocks.ListBlock(
+                            wagtail.core.blocks.StructBlock(
+                                [
+                                    ("question", wagtail.core.blocks.TextBlock()),
+                                    ("answer", wagtail.core.blocks.RichTextBlock()),
+                                ],
+                                template="regulace_konopi/blocks/faq.html",
+                            ),
+                            label="faq",
+                        ),
+                    ),
+                    (
+                        "meps",
+                        wagtail.core.blocks.StructBlock(
+                            [
+                                ("name", wagtail.core.blocks.CharBlock(label="název")),
+                                (
+                                    "mep",
+                                    wagtail.core.blocks.ListBlock(
+                                        wagtail.core.blocks.StructBlock(
+                                            [
+                                                (
+                                                    "name",
+                                                    wagtail.core.blocks.CharBlock(
+                                                        label="jméno"
+                                                    ),
+                                                ),
+                                                (
+                                                    "approved",
+                                                    wagtail.core.blocks.ChoiceBlock(
+                                                        choices=[
+                                                            (1, "Pro"),
+                                                            (0, "Proti"),
+                                                            (-1, "NevĂ­me"),
+                                                        ],
+                                                        label="hlasoval",
+                                                    ),
+                                                ),
+                                            ]
+                                        )
+                                    ),
+                                ),
+                            ],
+                            template="regulace_konopi/blocks/party.html",
+                        ),
+                    ),
+                    (
+                        "text_3_columns",
+                        wagtail.core.blocks.StreamBlock(
+                            [
+                                (
+                                    "column",
+                                    wagtail.core.blocks.RichTextBlock(
+                                        features=[
+                                            "h2",
+                                            "h3",
+                                            "h4",
+                                            "h5",
+                                            "bold",
+                                            "italic",
+                                            "ol",
+                                            "ul",
+                                            "hr",
+                                            "link",
+                                            "document-link",
+                                            "image",
+                                            "superscript",
+                                            "subscript",
+                                            "strikethrough",
+                                            "blockquote",
+                                        ],
+                                        label="column",
+                                    ),
+                                )
+                            ],
+                            icon="doc-full",
+                            max_num=3,
+                        ),
+                    ),
+                ],
+                blank=True,
+                verbose_name="obsah stránky",
+            ),
+        ),
+    ]
diff --git a/regulace_konopi/models.py b/regulace_konopi/models.py
index 121ccabd..b7ec50b9 100644
--- a/regulace_konopi/models.py
+++ b/regulace_konopi/models.py
@@ -69,6 +69,11 @@ class FaqBlock(blocks.StructBlock):
     answer = blocks.RichTextBlock()
 
 
+class ThreeColumnsBlock(blocks.StructBlock):
+    first_column = blocks.RichTextBlock(features=RICH_TEXT_FEATURES)
+    second_column = blocks.RichTextBlock(features=RICH_TEXT_FEATURES)
+
+
 class RegkonHomePage(MetadataPageMixin, Page):
     ### FIELDS
     content = StreamField(
@@ -176,7 +181,7 @@ class RegkonSubPage(Page, MetadataPageMixin):
                 blocks.ListBlock(
                     blocks.RichTextBlock(features=RICH_TEXT_FEATURES),
                     label="carousel-text",
-                    icon="paragraph",
+                    icon="image",
                 ),
             ),
             (
@@ -186,6 +191,21 @@ class RegkonSubPage(Page, MetadataPageMixin):
                 ),
             ),
             ("meps", PartyBlock(template="regulace_konopi/blocks/party.html")),
+            (
+                "text_3_columns",
+                blocks.StreamBlock(
+                    [
+                        (
+                            "column",
+                            blocks.RichTextBlock(
+                                label="column", features=RICH_TEXT_FEATURES
+                            ),
+                        )
+                    ],
+                    max_num=3,
+                    icon="doc-full",
+                ),
+            ),
         ],
         verbose_name="obsah stránky",
         blank=True,
@@ -214,8 +234,11 @@ class RegkonSubPage(Page, MetadataPageMixin):
 
     ### RELATIONS
 
-    parent_page_types = ["regulace_konopi.RegkonHomePage"]
-    subpage_types = []
+    parent_page_types = [
+        "regulace_konopi.RegkonHomePage",
+        "regulace_konopi.RegkonSubPage",
+    ]
+    subpage_types = ["regulace_konopi.RegkonSubPage"]
 
     ### OTHERS
 
diff --git a/regulace_konopi/templates/regulace_konopi/base.html b/regulace_konopi/templates/regulace_konopi/base.html
index b9f264fe..056940e5 100644
--- a/regulace_konopi/templates/regulace_konopi/base.html
+++ b/regulace_konopi/templates/regulace_konopi/base.html
@@ -14,7 +14,7 @@
   {% include "shared/favicon_snippet.html" %}
 
   <!-- Styles -->
-  <link href="{% static "regulace_konopi/vendor/css/bootstrap.min.css" %}" rel="stylesheet"/>
+  <link href="{% static "shared/vendor/bootstrap-4.4.1/css/bootstrap.min.css" %}" rel="stylesheet"/>
   <link href="{% static "styleguide18/assets/css/styles.css" %}" rel="stylesheet" media="all"/>
   <link href="{% static "styleguide18/assets/css/pattern-scaffolding.css" %}" rel="stylesheet" media="all"/>
   <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet">
@@ -120,7 +120,7 @@
   </ui-app>
 </footer>
 
-<script src="{% static "regulace_konopi/vendor/js/bootstrap.bundle.min.js" %}"></script>
+<script src="{% static "shared/vendor/bootstrap-4.4.1/js/bootstrap.min.js" %}"></script>
 <script src="{% static "styleguide18/assets/js/vue.2.6.11.js" %}"></script>
 <script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script>
 <script src="{% static "shared/vendor/fancybox/jquery.fancybox.min.js" %}"></script>
diff --git a/regulace_konopi/templates/regulace_konopi/snippet_sections.html b/regulace_konopi/templates/regulace_konopi/snippet_sections.html
index 0b8800b7..a88fe8d5 100644
--- a/regulace_konopi/templates/regulace_konopi/snippet_sections.html
+++ b/regulace_konopi/templates/regulace_konopi/snippet_sections.html
@@ -26,6 +26,16 @@
       </div>
     {% endif %}
 
+    {% if block.block_type == "text_3_columns" %}
+        <div class="lg:flex clearfix">
+          {% for column in block.value %}
+          <div class="content-block lg:w-1/3 text-center text-justify">
+            {{ column.value|richtext }}
+          </div>
+          {% endfor %}
+        </div>
+    {% endif %}
+
     {% if block.block_type == "carousel" %}
       <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
         <div class="carousel-inner">
-- 
GitLab