diff --git a/district/blocks.py b/district/blocks.py index 3ef570aea038855c4ca33af2316eaeaece873b73..7a29e7414a00500ed2fb68e175dc6a8512dff689 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 0000000000000000000000000000000000000000..7ec56b0b927aa4220c770604563d5ce4d863c3de --- /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 4a3484e41910a488b5d68d9a193dc8c3738b37ce..e5b2a7a5e9565089beea612a9520efff37bd96a8 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 444fa86578603a4a928597dd6c34f6f84d67cdfb..79a75a9e1d19e4e3bb30c3690a21afd6613b9721 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 678ce52e9a3d83a7b7b38982a8d1706ef6ba3f7a..39942e2617c276294e30dab59284b266c414d617 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 0000000000000000000000000000000000000000..e1ae7abfa8c9511241cbe1ae3e291d3a11822f4f --- /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 84e7443122a50acc42460074a0e1fc29636fbb10..5485313221efd72fc399924b1500161116b0fb0d 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 4c063a7c277484b217664f84ad93c2bf49a6887b..95d287d83cd532c948c71b2c7e3006b31ca14e27 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>