From 07b6477b238418bf02ce3e2397ab41e5bc36a993 Mon Sep 17 00:00:00 2001
From: OndraRehounek <ondra.rehounek@seznam.cz>
Date: Thu, 14 Apr 2022 16:06:38 +0200
Subject: [PATCH] district & region: HTML content in TableBlock

---
 ...ter_districtcenterpage_content_and_more.py | 76 +++++++++++++++++++
 district/models.py                            |  4 +-
 ...alter_regioncenterpage_content_and_more.py | 76 +++++++++++++++++++
 region/models.py                              |  4 +-
 shared/static/shared/css/helpers.css          |  5 ++
 5 files changed, 161 insertions(+), 4 deletions(-)
 create mode 100644 district/migrations/0054_alter_districtcenterpage_content_and_more.py
 create mode 100644 region/migrations/0029_alter_regioncenterpage_content_and_more.py

diff --git a/district/migrations/0054_alter_districtcenterpage_content_and_more.py b/district/migrations/0054_alter_districtcenterpage_content_and_more.py
new file mode 100644
index 00000000..c83fb639
--- /dev/null
+++ b/district/migrations/0054_alter_districtcenterpage_content_and_more.py
@@ -0,0 +1,76 @@
+# Generated by Django 4.0.3 on 2022-04-14 14:06
+
+import wagtail.contrib.table_block.blocks
+import wagtail.core.blocks
+import wagtail.core.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("district", "0053_alter_districtcrossroadpage_cards_content"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="districtcenterpage",
+            name="content",
+            field=wagtail.core.fields.StreamField(
+                [
+                    ("text", wagtail.core.blocks.RichTextBlock()),
+                    (
+                        "table",
+                        wagtail.contrib.table_block.blocks.TableBlock(
+                            table_options={"renderer": "html"}
+                        ),
+                    ),
+                ],
+                blank=True,
+                verbose_name="Obsah",
+            ),
+        ),
+        migrations.AlterField(
+            model_name="districtcustompage",
+            name="content",
+            field=wagtail.core.fields.StreamField(
+                [
+                    ("text", wagtail.core.blocks.RichTextBlock()),
+                    (
+                        "table",
+                        wagtail.contrib.table_block.blocks.TableBlock(
+                            table_options={"renderer": "html"}
+                        ),
+                    ),
+                    (
+                        "people_group",
+                        wagtail.core.blocks.StructBlock(
+                            [
+                                (
+                                    "group_title",
+                                    wagtail.core.blocks.CharBlock(
+                                        label="Titulek", required=True
+                                    ),
+                                ),
+                                (
+                                    "person_list",
+                                    wagtail.core.blocks.ListBlock(
+                                        wagtail.core.blocks.PageChooserBlock(
+                                            label="Osoba",
+                                            page_type=[
+                                                "district.DistrictPersonPage",
+                                                "region.RegionPersonPage",
+                                            ],
+                                        ),
+                                        label="List osob",
+                                    ),
+                                ),
+                            ]
+                        ),
+                    ),
+                ],
+                blank=True,
+                verbose_name="Obsah",
+            ),
+        ),
+    ]
diff --git a/district/models.py b/district/models.py
index 4c946bd7..2aaa34ce 100644
--- a/district/models.py
+++ b/district/models.py
@@ -888,7 +888,7 @@ class DistrictCenterPage(CalendarMixin, SubpageMixin, MetadataPageMixin, Page):
     content = StreamField(
         [
             ("text", RichTextBlock()),
-            ("table", TableBlock()),
+            ("table", TableBlock(table_options={"renderer": "html"})),
         ],
         verbose_name="Obsah",
         blank=True,
@@ -1001,7 +1001,7 @@ class DistrictCustomPage(SubpageMixin, MetadataPageMixin, Page):
     content = StreamField(
         [
             ("text", RichTextBlock()),
-            ("table", TableBlock()),
+            ("table", TableBlock(table_options={"renderer": "html"})),
             ("people_group", blocks.PeopleGroupListBlock()),
         ],
         verbose_name="Obsah",
diff --git a/region/migrations/0029_alter_regioncenterpage_content_and_more.py b/region/migrations/0029_alter_regioncenterpage_content_and_more.py
new file mode 100644
index 00000000..49ce1df6
--- /dev/null
+++ b/region/migrations/0029_alter_regioncenterpage_content_and_more.py
@@ -0,0 +1,76 @@
+# Generated by Django 4.0.3 on 2022-04-14 14:06
+
+import wagtail.contrib.table_block.blocks
+import wagtail.core.blocks
+import wagtail.core.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("region", "0028_alter_regioncrossroadpage_cards_content"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="regioncenterpage",
+            name="content",
+            field=wagtail.core.fields.StreamField(
+                [
+                    ("text", wagtail.core.blocks.RichTextBlock()),
+                    (
+                        "table",
+                        wagtail.contrib.table_block.blocks.TableBlock(
+                            table_options={"renderer": "html"}
+                        ),
+                    ),
+                ],
+                blank=True,
+                verbose_name="Obsah",
+            ),
+        ),
+        migrations.AlterField(
+            model_name="regioncustompage",
+            name="content",
+            field=wagtail.core.fields.StreamField(
+                [
+                    ("text", wagtail.core.blocks.RichTextBlock()),
+                    (
+                        "table",
+                        wagtail.contrib.table_block.blocks.TableBlock(
+                            table_options={"renderer": "html"}
+                        ),
+                    ),
+                    (
+                        "people_group",
+                        wagtail.core.blocks.StructBlock(
+                            [
+                                (
+                                    "group_title",
+                                    wagtail.core.blocks.CharBlock(
+                                        label="Titulek", required=True
+                                    ),
+                                ),
+                                (
+                                    "person_list",
+                                    wagtail.core.blocks.ListBlock(
+                                        wagtail.core.blocks.PageChooserBlock(
+                                            label="Osoba",
+                                            page_type=[
+                                                "district.DistrictPersonPage",
+                                                "region.RegionPersonPage",
+                                            ],
+                                        ),
+                                        label="List osob",
+                                    ),
+                                ),
+                            ]
+                        ),
+                    ),
+                ],
+                blank=True,
+                verbose_name="Obsah",
+            ),
+        ),
+    ]
diff --git a/region/models.py b/region/models.py
index d1f6072b..6f4c6349 100644
--- a/region/models.py
+++ b/region/models.py
@@ -874,7 +874,7 @@ class RegionCenterPage(CalendarMixin, SubpageMixin, MetadataPageMixin, Page):
     content = StreamField(
         [
             ("text", RichTextBlock()),
-            ("table", TableBlock()),
+            ("table", TableBlock(table_options={"renderer": "html"})),
         ],
         verbose_name="Obsah",
         blank=True,
@@ -987,7 +987,7 @@ class RegionCustomPage(SubpageMixin, MetadataPageMixin, Page):
     content = StreamField(
         [
             ("text", RichTextBlock()),
-            ("table", TableBlock()),
+            ("table", TableBlock(table_options={"renderer": "html"})),
             ("people_group", blocks.PeopleGroupListBlock()),
         ],
         verbose_name="Obsah",
diff --git a/shared/static/shared/css/helpers.css b/shared/static/shared/css/helpers.css
index 0ba59e24..7123673d 100644
--- a/shared/static/shared/css/helpers.css
+++ b/shared/static/shared/css/helpers.css
@@ -1,3 +1,8 @@
+table caption {
+    font-weight: 700;
+    text-align: left;
+}
+
 .responsive-object {
     position: relative;
 }
-- 
GitLab