diff --git a/district/migrations/0109_districthomepage_footer_links.py b/district/migrations/0109_districthomepage_footer_links.py new file mode 100644 index 0000000000000000000000000000000000000000..a0426d474a4d575f5ec35cae8c5e13a0d34728c3 --- /dev/null +++ b/district/migrations/0109_districthomepage_footer_links.py @@ -0,0 +1,61 @@ +# Generated by Django 4.1.8 on 2023-04-20 21:55 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0108_alter_districtcenterpage_content_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="districthomepage", + name="footer_links", + field=wagtail.fields.StreamField( + [ + ( + "footer_links", + wagtail.blocks.StructBlock( + [ + ( + "label", + wagtail.blocks.CharBlock( + label="Titulek zápatí", required=True + ), + ), + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "url", + wagtail.blocks.URLBlock( + label="Odkaz" + ), + ), + ( + "text", + wagtail.blocks.CharBlock( + label="Text v odkazu" + ), + ), + ] + ), + label="Odkazy", + required=True, + ), + ), + ] + ), + ) + ], + blank=True, + use_json_field=True, + verbose_name="Odkazy v zápatí webu", + ), + ), + ] diff --git a/district/models.py b/district/models.py index 54e425367a24b6711e8206344ef31e5d02bfa254..f7f7589217e8f08afc37ab1cebaffe85391f94b2 100644 --- a/district/models.py +++ b/district/models.py @@ -40,6 +40,7 @@ from shared.blocks import ( ButtonGroupBlock, ChartBlock, FigureBlock, + FooterLinksBlock, FullSizeHeaderBlock, HeadlineBlock, YouTubeVideoBlock, @@ -49,6 +50,7 @@ from shared.models import ( ArticleMixin, ExtendedMetadataHomePageMixin, ExtendedMetadataPageMixin, + FooterMixin, MenuMixin, SubpageMixin, ) @@ -66,7 +68,12 @@ CONTENT_BLOCKS = DEFAULT_CONTENT_BLOCKS + [ class DistrictHomePage( - MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, CalendarMixin, Page + MenuMixin, + ExtendedMetadataHomePageMixin, + MetadataPageMixin, + CalendarMixin, + FooterMixin, + Page, ): ### FIELDS @@ -267,6 +274,7 @@ class DistrictHomePage( ], gettext_lazy("Nastavení lišty s kalendářem a mapou"), ), + FieldPanel("footer_links"), FieldPanel("fallback_image"), ] diff --git a/district/templates/district/base.html b/district/templates/district/base.html index 360bdcf8af6b7f0c7162013a380287b650489132..35fc5e4c97d95744d1e76cec938db36606cff391 100644 --- a/district/templates/district/base.html +++ b/district/templates/district/base.html @@ -287,6 +287,10 @@ </ul> </ui-footer-collapsible> </div> + + {% if page.root_page.footer_links %} + {% include_block page.root_page.footer_links with container="py-4 lg:py-0 border-t border-grey-400 lg:border-t-0" %} + {% endif %} </section> <section class="footer__social lg:text-right"> diff --git a/senate/migrations/0006_senatehomepage_footer_links.py b/senate/migrations/0006_senatehomepage_footer_links.py new file mode 100644 index 0000000000000000000000000000000000000000..c09a5f8c5042b5a546442fdc4f24c4bb04ef0d40 --- /dev/null +++ b/senate/migrations/0006_senatehomepage_footer_links.py @@ -0,0 +1,61 @@ +# Generated by Django 4.1.8 on 2023-04-20 21:55 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("senate", "0005_alter_senatehomepage_candidates_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="senatehomepage", + name="footer_links", + field=wagtail.fields.StreamField( + [ + ( + "footer_links", + wagtail.blocks.StructBlock( + [ + ( + "label", + wagtail.blocks.CharBlock( + label="Titulek zápatí", required=True + ), + ), + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "url", + wagtail.blocks.URLBlock( + label="Odkaz" + ), + ), + ( + "text", + wagtail.blocks.CharBlock( + label="Text v odkazu" + ), + ), + ] + ), + label="Odkazy", + required=True, + ), + ), + ] + ), + ) + ], + blank=True, + use_json_field=True, + verbose_name="Odkazy v zápatí webu", + ), + ), + ] diff --git a/senate/models.py b/senate/models.py index 8b3facef72b25bc08a756080c8ef11f1c9df2aff..cc62e29bf1e123062ea4da7e74ecb2106155373f 100644 --- a/senate/models.py +++ b/senate/models.py @@ -8,6 +8,8 @@ from wagtail.images.edit_handlers import FieldPanel from wagtail.models import Page from wagtailmetadata.models import MetadataPageMixin +from shared.blocks import FooterLinksBlock +from shared.models import FooterMixin from tuning import admin_help @@ -25,7 +27,7 @@ class PersonBlock(blocks.StructBlock): label = "osoba" -class SenateHomePage(MetadataPageMixin, Page): +class SenateHomePage(MetadataPageMixin, FooterMixin, Page): ### FIELDS senators = StreamField( @@ -70,7 +72,11 @@ class SenateHomePage(MetadataPageMixin, Page): ), ] - settings_panels = [FieldPanel("matomo_id"), CommentPanel()] + settings_panels = [ + FieldPanel("matomo_id"), + FieldPanel("footer_links"), + CommentPanel(), + ] ### RELATIONS diff --git a/senate/templates/senate/base.html b/senate/templates/senate/base.html index bcbab5841b7526968383e3cdee6b13698747eb1a..149063110367eebf5f61b384f3ce98fa0ddaac9c 100644 --- a/senate/templates/senate/base.html +++ b/senate/templates/senate/base.html @@ -69,6 +69,9 @@ </div> </a> </div> + {% if page.footer_links %} + {% include_block page.footer_links with container="col-sm-5 col-12" %} + {% endif %} </div> </div> </div> diff --git a/shared/blocks.py b/shared/blocks.py index 869a45551714a4a4f23442f72b47135a7d125f94..db1c733921fc328513654527a02d6576e0d35f94 100644 --- a/shared/blocks.py +++ b/shared/blocks.py @@ -730,7 +730,9 @@ class ChartRedmineIssueDataset(blocks.StructBlock): required=False, ) - def _get_issues_url(self, value, project_id: typing.Union[None, str, list[str]] = None): + def _get_issues_url( + self, value, project_id: typing.Union[None, str, list[str]] = None + ): url = "https://redmine.pirati.cz/issues.json" params = [ ("sort", "created_on"), @@ -1042,6 +1044,25 @@ class ChartBlock(blocks.StructBlock): Zobrazí se tolik definovaných sloupců, kolik existuje skupin.""" +class FooterLinksBlock(blocks.StructBlock): + label = blocks.CharBlock(label="Titulek zápatí", required=True) + items = blocks.ListBlock( + blocks.StructBlock( + [ + ("url", blocks.URLBlock(label="Odkaz")), + ("text", blocks.CharBlock(label="Text v odkazu")), + ] + ), + label="Odkazy", + required=True, + ) + + class Meta: + label = "Seznam odkazů v zápatí" + icon = "list-ul" + template = "shared/blocks/footer_links_block.html" + + DEFAULT_CONTENT_BLOCKS = [ ( "text", diff --git a/shared/models.py b/shared/models.py index 44924a502f840168fc695196c754f8ca8ae4def9..5d63c346cf814863392adc444524bcf88981bb7f 100644 --- a/shared/models.py +++ b/shared/models.py @@ -6,7 +6,12 @@ from wagtail.admin.panels import FieldPanel, MultiFieldPanel, PublishingPanel from wagtail.fields import StreamField from wagtail.models import Page -from shared.blocks import DEFAULT_CONTENT_BLOCKS, MenuItemBlock, MenuParentBlock +from shared.blocks import ( + DEFAULT_CONTENT_BLOCKS, + FooterLinksBlock, + MenuItemBlock, + MenuParentBlock, +) logger = logging.getLogger(__name__) @@ -192,3 +197,18 @@ class ExtendedMetadataPageMixin(models.Model): return super().get_meta_title() return f"{super().get_meta_title()} | {self.get_meta_title_suffix()}" + + +class FooterMixin(models.Model): + footer_links = StreamField( + [ + ("footer_links", FooterLinksBlock()), + ], + verbose_name="Odkazy v zápatí webu", + blank=True, + max_num=1, + use_json_field=True, + ) + + class Meta: + abstract = True diff --git a/shared/templates/shared/blocks/footer_links_block.html b/shared/templates/shared/blocks/footer_links_block.html new file mode 100644 index 0000000000000000000000000000000000000000..ebc55cb0054ea6f9b689202742371ca0f86b71b9 --- /dev/null +++ b/shared/templates/shared/blocks/footer_links_block.html @@ -0,0 +1,9 @@ +<div class="{{ container }}"> + <ui-footer-collapsible label="{{ self.label }}"> + <ul class="mt-6 space-y-2 text-grey-200"> + {% for item in self.items %} + <li><a href="{{ item.url }}">{{ item.text }}</a></li> + {% endfor %} + </ul> + </ui-footer-collapsible> +</div> diff --git a/uniweb/migrations/0042_uniwebhomepage_footer_links.py b/uniweb/migrations/0042_uniwebhomepage_footer_links.py new file mode 100644 index 0000000000000000000000000000000000000000..0e5c44f70fac7564781219e283c25a6bda6b8f50 --- /dev/null +++ b/uniweb/migrations/0042_uniwebhomepage_footer_links.py @@ -0,0 +1,61 @@ +# Generated by Django 4.1.8 on 2023-04-20 21:55 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("uniweb", "0041_alter_uniwebflexiblepage_content_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="uniwebhomepage", + name="footer_links", + field=wagtail.fields.StreamField( + [ + ( + "footer_links", + wagtail.blocks.StructBlock( + [ + ( + "label", + wagtail.blocks.CharBlock( + label="Titulek zápatí", required=True + ), + ), + ( + "items", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "url", + wagtail.blocks.URLBlock( + label="Odkaz" + ), + ), + ( + "text", + wagtail.blocks.CharBlock( + label="Text v odkazu" + ), + ), + ] + ), + label="Odkazy", + required=True, + ), + ), + ] + ), + ) + ], + blank=True, + use_json_field=True, + verbose_name="Odkazy v zápatí webu", + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index 70f746cb0949efbbea794c13da4f3be4d3e2ac66..423ad0481b51c2436c7197d100ae02d1333cfd08 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -25,18 +25,19 @@ from wagtail.models import Page from wagtailmetadata.models import MetadataPageMixin from calendar_utils.models import CalendarMixin -from shared.blocks import ChartBlock +from shared.blocks import ChartBlock, FooterLinksBlock from shared.const import RICH_TEXT_DEFAULT_FEATURES from shared.models import ( ArticleMixin, ExtendedMetadataHomePageMixin, ExtendedMetadataPageMixin, + FooterMixin, SubpageMixin, ) from shared.utils import make_promote_panels, strip_all_html_tags, trim_to_length from tuning import admin_help -from .blocks import PeopleGroupListBlock, PersonCustomPositionBlock, PersonUrlBlock +from .blocks import PeopleGroupListBlock, PersonUrlBlock from .constants import ( ALIGN_CHOICES, ALIGN_CSS, @@ -300,7 +301,7 @@ class UniwebArticleTag(TaggedItemBase): class UniwebHomePage( - Page, ExtendedMetadataHomePageMixin, MetadataPageMixin, CalendarMixin + Page, ExtendedMetadataHomePageMixin, MetadataPageMixin, CalendarMixin, FooterMixin ): ### FIELDS @@ -330,6 +331,7 @@ class UniwebHomePage( ) ### Footer + show_logo = models.BooleanField( "zobrazit logo", default=True, help_text="Zobrazit logo" ) @@ -369,6 +371,7 @@ class UniwebHomePage( FieldPanel("show_social_links"), FieldPanel("show_pirate_buttons"), FieldPanel("footer_extra_content"), + FieldPanel("footer_links"), ], "nastavení patičky", ), diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index 733e7c914bb3a376b317ed6d2abf6c735121df65..7522bd1ade5a28957a1d414c46a543c6b3914e54 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -133,6 +133,9 @@ {% endif %} </div> </section> + {% if page.root_page.footer_links %} + {% include_block page.root_page.footer_links with container="flex flex-col md:flex-row lg:flex-col lg:items-end space-y-2 md:space-y-0 md:space-x-2 lg:space-x-0 lg:space-y-2" %} + {% endif %} </div> </div> </ui-app>