diff --git a/district/migrations/0060_alter_districtarticlepage_content.py b/district/migrations/0060_alter_districtarticlepage_content_and_more.py similarity index 60% rename from district/migrations/0060_alter_districtarticlepage_content.py rename to district/migrations/0060_alter_districtarticlepage_content_and_more.py index 2414b4a4316375fa92ae7dd3083f0a3cd78b8bba..803bc825c43060c6cfe762331419897d33e062cf 100644 --- a/district/migrations/0060_alter_districtarticlepage_content.py +++ b/district/migrations/0060_alter_districtarticlepage_content_and_more.py @@ -1,5 +1,6 @@ -# Generated by Django 4.0.3 on 2022-04-28 08:35 +# Generated by Django 4.0.3 on 2022-04-28 09:31 +import wagtail.contrib.table_block.blocks import wagtail.core.blocks import wagtail.core.fields import wagtail.images.blocks @@ -93,4 +94,64 @@ class Migration(migrations.Migration): verbose_name="Článek", ), ), + migrations.AlterField( + model_name="districtcenterpage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ("text", wagtail.core.blocks.RichTextBlock()), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + template="shared/blocks/table_block.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( + template="shared/blocks/table_block.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 3d877d89fbd5bd37b3dbff1198f652f0fadaa7cd..51863f642ffc98e8a98940813bb97b620a2eac20 100644 --- a/district/models.py +++ b/district/models.py @@ -922,7 +922,7 @@ class DistrictCenterPage( content = StreamField( [ ("text", RichTextBlock()), - ("table", TableBlock()), + ("table", TableBlock(template="shared/blocks/table_block.html")), ], verbose_name="Obsah", blank=True, @@ -1039,7 +1039,7 @@ class DistrictCustomPage( content = StreamField( [ ("text", RichTextBlock()), - ("table", TableBlock()), + ("table", TableBlock(template="shared/blocks/table_block.html")), ("people_group", blocks.PeopleGroupListBlock()), ], verbose_name="Obsah", diff --git a/region/migrations/0035_alter_regionarticlepage_content.py b/region/migrations/0035_alter_regionarticlepage_content_and_more.py similarity index 60% rename from region/migrations/0035_alter_regionarticlepage_content.py rename to region/migrations/0035_alter_regionarticlepage_content_and_more.py index 2a4c8cc4aeb9001a28e87cf1a137dff6631fb39b..3b9a8aaaffc2cf3017a32458a21e237d1aa48226 100644 --- a/region/migrations/0035_alter_regionarticlepage_content.py +++ b/region/migrations/0035_alter_regionarticlepage_content_and_more.py @@ -1,5 +1,6 @@ -# Generated by Django 4.0.3 on 2022-04-28 08:35 +# Generated by Django 4.0.3 on 2022-04-28 09:31 +import wagtail.contrib.table_block.blocks import wagtail.core.blocks import wagtail.core.fields import wagtail.images.blocks @@ -93,4 +94,64 @@ class Migration(migrations.Migration): verbose_name="Článek", ), ), + migrations.AlterField( + model_name="regioncenterpage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ("text", wagtail.core.blocks.RichTextBlock()), + ( + "table", + wagtail.contrib.table_block.blocks.TableBlock( + template="shared/blocks/table_block.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( + template="shared/blocks/table_block.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 109dfc959908849e81c7c628c375d782eee84e0a..5531f0f7eaa247700b4db8f14c357b8d9c4c06b6 100644 --- a/region/models.py +++ b/region/models.py @@ -907,7 +907,7 @@ class RegionCenterPage( content = StreamField( [ ("text", RichTextBlock()), - ("table", TableBlock()), + ("table", TableBlock(template="shared/blocks/table_block.html")), ], verbose_name="Obsah", blank=True, @@ -1024,7 +1024,7 @@ class RegionCustomPage( content = StreamField( [ ("text", RichTextBlock()), - ("table", TableBlock()), + ("table", TableBlock(template="shared/blocks/table_block.html")), ("people_group", blocks.PeopleGroupListBlock()), ], verbose_name="Obsah", diff --git a/shared/templates/shared/blocks/table_block.html b/shared/templates/shared/blocks/table_block.html new file mode 100644 index 0000000000000000000000000000000000000000..5adfe4166a7ca841bcb7ad6ad15fb0e7a5b63c2b --- /dev/null +++ b/shared/templates/shared/blocks/table_block.html @@ -0,0 +1,49 @@ +{% load table_block_tags shared_filters %} + +<div class="my-6"> + <table class="table table--bordered content-block"> + {% if table_caption %} + <caption class="head-heavy-sm my-4">{{ table_caption }}</caption> + {% endif %} + {% if table_header %} + <thead> + <tr> + {% for column in table_header %} + {% with forloop.counter0 as col_index %} + <th scope="col" {% cell_classname 0 col_index %}> + {% if column.strip %} + {{ column.strip|markdown }} + {% endif %} + </th> + {% endwith %} + {% endfor %} + </tr> + </thead> + {% endif %} + <tbody> + {% for row in data %} + {% with forloop.counter0 as row_index %} + <tr> + {% for column in row %} + {% with forloop.counter0 as col_index %} + {% if first_col_is_header and forloop.first %} + <th scope="row" {% cell_classname row_index col_index table_header %}> + {% if column.strip %} + {{ column.strip|markdown }} + {% endif %} + </th> + {% else %} + <td {% cell_classname row_index col_index table_header %}> + {% if column.strip %} + {{ column.strip|markdown }} + {% endif %} + </td> + {% endif %} + {% endwith %} + {% endfor %} + </tr> + {% endwith %} + {% endfor %} + </tbody> + </table> +</div> diff --git a/uniweb/migrations/0025_alter_uniwebarticlepage_content.py b/uniweb/migrations/0025_alter_uniwebarticlepage_content.py index 500ab523b76e90656d00fd8ca718df736f384109..a9fc245aa42065064316cdd8406e8a01312d375d 100644 --- a/uniweb/migrations/0025_alter_uniwebarticlepage_content.py +++ b/uniweb/migrations/0025_alter_uniwebarticlepage_content.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.3 on 2022-04-28 08:35 +# Generated by Django 4.0.3 on 2022-04-28 09:31 import wagtail.core.blocks import wagtail.core.fields