From 473b289f53a2a9050f59e129287483b425fb8d1d Mon Sep 17 00:00:00 2001 From: OndraRehounek <ondra.rehounek@seznam.cz> Date: Thu, 3 Mar 2022 09:47:20 +0100 Subject: [PATCH] district and region: Person other links --- district/blocks.py | 10 ++++ .../0036_districtpersonpage_other_urls.py | 52 +++++++++++++++++++ district/models.py | 20 +++---- .../district/district_person_page.html | 11 ++++ region/blocks.py | 10 ++++ .../0013_regionpersonpage_other_urls.py | 52 +++++++++++++++++++ region/models.py | 19 +++---- .../templates/region/region_person_page.html | 11 ++++ 8 files changed, 159 insertions(+), 26 deletions(-) create mode 100644 district/migrations/0036_districtpersonpage_other_urls.py create mode 100644 region/migrations/0013_regionpersonpage_other_urls.py diff --git a/district/blocks.py b/district/blocks.py index 3ef570ae..7a29e741 100644 --- a/district/blocks.py +++ b/district/blocks.py @@ -138,6 +138,16 @@ class PeopleGroupListBlock(StructBlock): label = "Skupina členů" +class PersonUrlBlock(StructBlock): + title = CharBlock(label="Název", required=True) + url = URLBlock(label="URL", required=True) + custom_icon = CharBlock( + label="Vlastní ikonka ze styleguide", + required=False, + help_text="Pro vlastní ikonku zadejde název ikonky z https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons (bez tečky), např. 'ico--beer'", + ) + + class ProgramItemBlock(StructBlock): title = CharBlock(label="Název", required=True) completion_percentage = IntegerBlock(label="Procento dokončení", required=True) diff --git a/district/migrations/0036_districtpersonpage_other_urls.py b/district/migrations/0036_districtpersonpage_other_urls.py new file mode 100644 index 00000000..7ec56b0b --- /dev/null +++ b/district/migrations/0036_districtpersonpage_other_urls.py @@ -0,0 +1,52 @@ +# Generated by Django 3.2.11 on 2022-03-03 08:46 + +import wagtail.core.blocks +import wagtail.core.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("district", "0035_remove_districtpersonpage_perex"), + ] + + operations = [ + migrations.AddField( + model_name="districtpersonpage", + name="other_urls", + field=wagtail.core.fields.StreamField( + [ + ( + "other_url", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "url", + wagtail.core.blocks.URLBlock( + label="URL", required=True + ), + ), + ( + "custom_icon", + wagtail.core.blocks.CharBlock( + help_text="Pro vlastní ikonku zadejde název ikonky z https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons (bez tečky), např. 'ico--beer'", + label="Vlastní ikonka ze styleguide", + required=False, + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Další odkaz", + ), + ), + ] diff --git a/district/models.py b/district/models.py index 4a3484e4..e5b2a7a5 100644 --- a/district/models.py +++ b/district/models.py @@ -14,7 +14,6 @@ from wagtail.admin.edit_handlers import ( PageChooserPanel, StreamFieldPanel, ) -from wagtail.core import blocks from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Page from wagtail.images.edit_handlers import ImageChooserPanel @@ -24,18 +23,7 @@ from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, SubpageMixin from uniweb.constants import RICH_TEXT_FEATURES -from .blocks import ( - AddressBlock, - CandidateListBlock, - CenterContactBlock, - ContactItemBlock, - ElectionHeaderBlock, - HomepageHeaderBlock, - HomepageSimpleHeaderBlock, - PeopleGroupListBlock, - RedmineProgramBlock, - StaticProgramBlock, -) +from .blocks import * class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page): @@ -465,6 +453,11 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): twitter_url = models.URLField("Odkaz na Twitter", blank=True, null=True) youtube_url = models.URLField("Odkaz na Youtube kanál", blank=True, null=True) flickr_url = models.URLField("Odkaz na Flickr", blank=True, null=True) + other_urls = StreamField( + [("other_url", PersonUrlBlock())], + verbose_name="Další odkaz", + blank=True, + ) ### PANELS @@ -501,6 +494,7 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): FieldPanel("twitter_url"), FieldPanel("youtube_url"), FieldPanel("flickr_url"), + StreamFieldPanel("other_urls"), ], "Sociální sítě", ), diff --git a/district/templates/district/district_person_page.html b/district/templates/district/district_person_page.html index 444fa865..79a75a9e 100644 --- a/district/templates/district/district_person_page.html +++ b/district/templates/district/district_person_page.html @@ -62,6 +62,17 @@ <i class="ico--flickr"></i> </a> {% endif %} + {% for person_link_block in page.other_urls %} + <a + href="{{ person_link_block.value.url }}" + target="_blank" + class="social-icon" + rel="noreferrer noopener" + title="{{ person_link_block.value.title }}" + > + <i class="{% firstof person_link_block.value.custom_icon 'ico--globe' %}"></i> + </a> + {% endfor %} </div> <hr> diff --git a/region/blocks.py b/region/blocks.py index 678ce52e..39942e26 100644 --- a/region/blocks.py +++ b/region/blocks.py @@ -138,6 +138,16 @@ class PeopleGroupListBlock(StructBlock): label = "Skupina členů" +class PersonUrlBlock(StructBlock): + title = CharBlock(label="Název", required=True) + url = URLBlock(label="URL", required=True) + custom_icon = CharBlock( + label="Vlastní ikonka ze styleguide", + required=False, + help_text="Pro vlastní ikonku zadejde název ikonky z https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons (bez tečky), např. 'ico--beer'", + ) + + class ProgramItemBlock(StructBlock): title = CharBlock(label="Název", required=True) completion_percentage = IntegerBlock(label="Procento dokončení", required=True) diff --git a/region/migrations/0013_regionpersonpage_other_urls.py b/region/migrations/0013_regionpersonpage_other_urls.py new file mode 100644 index 00000000..e1ae7abf --- /dev/null +++ b/region/migrations/0013_regionpersonpage_other_urls.py @@ -0,0 +1,52 @@ +# Generated by Django 3.2.11 on 2022-03-03 08:46 + +import wagtail.core.blocks +import wagtail.core.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("region", "0012_remove_regionpersonpage_perex"), + ] + + operations = [ + migrations.AddField( + model_name="regionpersonpage", + name="other_urls", + field=wagtail.core.fields.StreamField( + [ + ( + "other_url", + wagtail.core.blocks.StructBlock( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + label="Název", required=True + ), + ), + ( + "url", + wagtail.core.blocks.URLBlock( + label="URL", required=True + ), + ), + ( + "custom_icon", + wagtail.core.blocks.CharBlock( + help_text="Pro vlastní ikonku zadejde název ikonky z https://styleguide.pirati.cz/latest/?p=viewall-atoms-icons (bez tečky), např. 'ico--beer'", + label="Vlastní ikonka ze styleguide", + required=False, + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Další odkaz", + ), + ), + ] diff --git a/region/models.py b/region/models.py index 84e74431..54853132 100644 --- a/region/models.py +++ b/region/models.py @@ -14,7 +14,6 @@ from wagtail.admin.edit_handlers import ( PageChooserPanel, StreamFieldPanel, ) -from wagtail.core import blocks from wagtail.core.fields import RichTextField, StreamField from wagtail.core.models import Page from wagtail.images.edit_handlers import ImageChooserPanel @@ -24,18 +23,7 @@ from calendar_utils.models import CalendarMixin from shared.models import ArticleMixin, SubpageMixin from uniweb.constants import RICH_TEXT_FEATURES -from .blocks import ( - AddressBlock, - CandidateListBlock, - CenterContactBlock, - ContactItemBlock, - ElectionHeaderBlock, - HomepageHeaderBlock, - HomepageSimpleHeaderBlock, - PeopleGroupListBlock, - RedmineProgramBlock, - StaticProgramBlock, -) +from .blocks import * class RegionHomePage(MetadataPageMixin, CalendarMixin, Page): @@ -461,6 +449,11 @@ class RegionPersonPage(SubpageMixin, MetadataPageMixin, Page): twitter_url = models.URLField("Odkaz na Twitter", blank=True, null=True) youtube_url = models.URLField("Odkaz na Youtube kanál", blank=True, null=True) flickr_url = models.URLField("Odkaz na Flickr", blank=True, null=True) + other_urls = StreamField( + [("other_url", PersonUrlBlock())], + verbose_name="Další odkaz", + blank=True, + ) ### PANELS diff --git a/region/templates/region/region_person_page.html b/region/templates/region/region_person_page.html index 4c063a7c..95d287d8 100644 --- a/region/templates/region/region_person_page.html +++ b/region/templates/region/region_person_page.html @@ -62,6 +62,17 @@ <i class="ico--flickr"></i> </a> {% endif %} + {% for person_link_block in page.other_urls %} + <a + href="{{ person_link_block.value.url }}" + target="_blank" + class="social-icon" + rel="noreferrer noopener" + title="{{ person_link_block.value.title }}" + > + <i class="{% firstof person_link_block.value.custom_icon 'ico--globe' %}"></i> + </a> + {% endfor %} </div> <hr> -- GitLab