From a0d9c86bb51e79750dfe9b07986c5ce160179bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Farka?= <stepanfarka11@gmail.com> Date: Fri, 25 Mar 2022 10:35:24 +0100 Subject: [PATCH] [ADD] PeopleGroupListBlock to custom page and crossroad page --- ..._districtcrossroadpage_content_and_more.py | 84 +++++++++++++++++++ district/models.py | 10 +++ .../district/district_crossroad_page.html | 5 ++ ...22_regioncrossroadpage_content_and_more.py | 84 +++++++++++++++++++ region/models.py | 10 +++ .../region/region_crossroad_page.html | 5 ++ 6 files changed, 198 insertions(+) create mode 100644 district/migrations/0047_districtcrossroadpage_content_and_more.py create mode 100644 region/migrations/0022_regioncrossroadpage_content_and_more.py diff --git a/district/migrations/0047_districtcrossroadpage_content_and_more.py b/district/migrations/0047_districtcrossroadpage_content_and_more.py new file mode 100644 index 00000000..ac5a0aa0 --- /dev/null +++ b/district/migrations/0047_districtcrossroadpage_content_and_more.py @@ -0,0 +1,84 @@ +# Generated by Django 4.0.3 on 2022-03-25 09:33 + +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", "0046_districtcenterpage_content"), + ] + + operations = [ + migrations.AddField( + model_name="districtcrossroadpage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "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"], + ), + label="List osob", + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Obsah stránky", + ), + ), + migrations.AlterField( + model_name="districtcustompage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ("text", wagtail.core.blocks.RichTextBlock()), + ("table", wagtail.contrib.table_block.blocks.TableBlock()), + ( + "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"], + ), + label="List osob", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="Obsah", + ), + ), + ] diff --git a/district/models.py b/district/models.py index a672aaba..7a95be5a 100644 --- a/district/models.py +++ b/district/models.py @@ -874,10 +874,19 @@ class DistrictCrossroadPage(SubpageMixin, MetadataPageMixin, Page): blank=True, ) + content = StreamField( + [ + ("people_group", blocks.PeopleGroupListBlock()), + ], + verbose_name="Obsah stránky", + blank=True, + ) + ### PANELS content_panels = Page.content_panels + [ StreamFieldPanel("cards_content"), + StreamFieldPanel("content"), ] ### RELATIONS @@ -912,6 +921,7 @@ class DistrictCustomPage(SubpageMixin, MetadataPageMixin, Page): [ ("text", RichTextBlock()), ("table", TableBlock()), + ("people_group", blocks.PeopleGroupListBlock()), ], verbose_name="Obsah", blank=True, diff --git a/district/templates/district/district_crossroad_page.html b/district/templates/district/district_crossroad_page.html index d628406a..12485466 100644 --- a/district/templates/district/district_crossroad_page.html +++ b/district/templates/district/district_crossroad_page.html @@ -8,5 +8,10 @@ {% include_block card_block %} {% endfor %} </div> + {% for block in page.content %} + <div class="content-block mb-8"> + {% include_block block %} + </div> + {% endfor %} </main> {% endblock %} diff --git a/region/migrations/0022_regioncrossroadpage_content_and_more.py b/region/migrations/0022_regioncrossroadpage_content_and_more.py new file mode 100644 index 00000000..c5fcddf3 --- /dev/null +++ b/region/migrations/0022_regioncrossroadpage_content_and_more.py @@ -0,0 +1,84 @@ +# Generated by Django 4.0.3 on 2022-03-25 09:33 + +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", "0021_regioncenterpage_content"), + ] + + operations = [ + migrations.AddField( + model_name="regioncrossroadpage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "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=["region.RegionPersonPage"], + ), + label="List osob", + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Obsah stránky", + ), + ), + migrations.AlterField( + model_name="regioncustompage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ("text", wagtail.core.blocks.RichTextBlock()), + ("table", wagtail.contrib.table_block.blocks.TableBlock()), + ( + "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=["region.RegionPersonPage"], + ), + label="List osob", + ), + ), + ] + ), + ), + ], + blank=True, + verbose_name="Obsah", + ), + ), + ] diff --git a/region/models.py b/region/models.py index 3bfdb435..25b8a2a9 100644 --- a/region/models.py +++ b/region/models.py @@ -867,10 +867,19 @@ class RegionCrossroadPage(SubpageMixin, MetadataPageMixin, Page): blank=True, ) + content = StreamField( + [ + ("people_group", blocks.PeopleGroupListBlock()), + ], + verbose_name="Obsah stránky", + blank=True, + ) + ### PANELS content_panels = Page.content_panels + [ StreamFieldPanel("cards_content"), + StreamFieldPanel("content"), ] ### RELATIONS @@ -905,6 +914,7 @@ class RegionCustomPage(SubpageMixin, MetadataPageMixin, Page): [ ("text", RichTextBlock()), ("table", TableBlock()), + ("people_group", blocks.PeopleGroupListBlock()), ], verbose_name="Obsah", blank=True, diff --git a/region/templates/region/region_crossroad_page.html b/region/templates/region/region_crossroad_page.html index 14c5a897..23294fb8 100644 --- a/region/templates/region/region_crossroad_page.html +++ b/region/templates/region/region_crossroad_page.html @@ -8,5 +8,10 @@ {% include_block card_block %} {% endfor %} </div> + {% for block in page.content %} + <div class="content-block mb-8"> + {% include_block block %} + </div> + {% endfor %} </main> {% endblock %} -- GitLab