diff --git a/elections2021/migrations/0018_auto_20210517_0158.py b/elections2021/migrations/0018_auto_20210517_0158.py new file mode 100644 index 0000000000000000000000000000000000000000..ce90bdd77b0e66cab5fbd21222b63d5b9f38cfe3 --- /dev/null +++ b/elections2021/migrations/0018_auto_20210517_0158.py @@ -0,0 +1,94 @@ +# Generated by Django 3.2.2 on 2021-05-16 23:58 + +import wagtail.core.blocks +import wagtail.core.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("elections2021", "0017_auto_20210517_0059"), + ] + + operations = [ + migrations.AlterModelOptions( + name="elections2021strategiclistpage", + options={"verbose_name": "Strategické dokumenty"}, + ), + migrations.AddField( + model_name="elections2021homepage", + name="footer_menu", + field=wagtail.core.fields.StreamField( + [ + ( + "item", + wagtail.core.blocks.StructBlock( + [ + ("name", wagtail.core.blocks.CharBlock(label="název")), + ( + "page", + wagtail.core.blocks.PageChooserBlock( + label="stránka", + page_type=[ + "elections2021.Elections2021ArticlesPage", + "elections2021.Elections2021CandidatesListPage", + "elections2021.Elections2021CandidatesMapPage", + "elections2021.Elections2021ProgramPage", + "elections2021.Elections2021QuestionsPage", + "elections2021.Elections2021ProgramAppPage", + "elections2021.Elections2021TextPage", + "elections2021.Elections2021StrategicListPage", + "elections2021.Elections2021StrategicPage", + ], + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="menu projděte si v zápatí", + ), + ), + migrations.AlterField( + model_name="elections2021strategicpage", + name="content", + field=wagtail.core.fields.StreamField( + [ + ( + "title", + wagtail.core.blocks.CharBlock( + icon="title", + label="nadpis sekce (pro navigaci)", + template="elections2021/_strategic_title_block.html", + ), + ), + ( + "text", + wagtail.core.blocks.RichTextBlock( + features=[ + "h3", + "h4", + "bold", + "italic", + "superscript", + "subscript", + "strikethrough", + "ul-elections2021", + "ol-elections2021", + "blockquote-elections2021", + "link", + "image", + "document-link", + ], + label="text", + template="elections2021/_strategic_text_block.html", + ), + ), + ], + blank=True, + verbose_name="obsah stránky", + ), + ), + ] diff --git a/elections2021/migrations/0019_elections2021homepage_gdpr_and_cookies_page.py b/elections2021/migrations/0019_elections2021homepage_gdpr_and_cookies_page.py new file mode 100644 index 0000000000000000000000000000000000000000..51ffe61a812b4f50448e896963324f4c3caadf3a --- /dev/null +++ b/elections2021/migrations/0019_elections2021homepage_gdpr_and_cookies_page.py @@ -0,0 +1,26 @@ +# Generated by Django 3.2.2 on 2021-05-17 00:10 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0062_comment_models_and_pagesubscription"), + ("elections2021", "0018_auto_20210517_0158"), + ] + + operations = [ + migrations.AddField( + model_name="elections2021homepage", + name="gdpr_and_cookies_page", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="+", + to="wagtailcore.page", + ), + ), + ] diff --git a/elections2021/models.py b/elections2021/models.py index 456cdbcb3166199d25f9e0e7189d460f60433cb8..525b3aaa4bbeaba2c7563dd3d30b8fe6e47676bc 100644 --- a/elections2021/models.py +++ b/elections2021/models.py @@ -18,6 +18,7 @@ from wagtail.admin.edit_handlers import ( HelpPanel, MultiFieldPanel, ObjectList, + PageChooserPanel, PublishingPanel, StreamFieldPanel, TabbedInterface, @@ -121,6 +122,27 @@ class LinkBlock(blocks.StructBlock): label = "odkaz" +class MenuItemBlock(blocks.StructBlock): + name = blocks.CharBlock(label="název") + page = blocks.PageChooserBlock( + label="stránka", + page_type=[ + "elections2021.Elections2021ArticlesPage", + "elections2021.Elections2021CandidatesListPage", + "elections2021.Elections2021CandidatesMapPage", + "elections2021.Elections2021ProgramPage", + "elections2021.Elections2021QuestionsPage", + "elections2021.Elections2021ProgramAppPage", + "elections2021.Elections2021TextPage", + "elections2021.Elections2021StrategicListPage", + "elections2021.Elections2021StrategicPage", + ], + ) + + class Meta: + label = "stránka" + + class Elections2021HomePage(Page, MetadataPageMixin): ### FIELDS @@ -130,6 +152,19 @@ class Elections2021HomePage(Page, MetadataPageMixin): footer_links = StreamField( [("link", LinkBlock())], verbose_name="odkazy v zápatí", blank=True ) + footer_menu = StreamField( + [("item", MenuItemBlock())], + verbose_name="menu projděte si v zápatí", + blank=True, + ) + gdpr_and_cookies_page = models.ForeignKey( + "wagtailcore.Page", + verbose_name="stránka GDPR a Cookies", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + ) matomo_id = models.IntegerField( "Matomo ID pro sledování návštěvnosti", blank=True, null=True ) @@ -149,9 +184,13 @@ class Elections2021HomePage(Page, MetadataPageMixin): ] settings_panels = [ - FieldPanel("matomo_id"), + StreamFieldPanel("footer_menu"), StreamFieldPanel("header_links"), StreamFieldPanel("footer_links"), + PageChooserPanel( + "gdpr_and_cookies_page", "elections2021.Elections2021TextPage" + ), + FieldPanel("matomo_id"), CommentPanel(), ] @@ -211,6 +250,12 @@ class Elections2021HomePage(Page, MetadataPageMixin): def program_app_page_url(self): return get_subpage_url(self, Elections2021ProgramAppPage) + @cached_property + def gdpr_and_cookies_url(self): + if self.gdpr_and_cookies_page: + return self.gdpr_and_cookies_page.url + return "#" + class Elections2021ArticleTag(TaggedItemBase): content_object = ParentalKey( diff --git a/elections2021/templates/elections2021/base.html b/elections2021/templates/elections2021/base.html index 47ee11834ba448396310c9dd2606ab720b85d809..df0f265ae334c3e6b683795a08a08f8fd518554c 100644 --- a/elections2021/templates/elections2021/base.html +++ b/elections2021/templates/elections2021/base.html @@ -116,29 +116,11 @@ <div class="pt-8 pb-4 lg:py-0"> <ui-footer-collapsible label="Projděte si"> <ul class="mt-4 md:mt-6 space-y-2 text-grey-200"> - <li> - <a href="{{ page.root_page.articles_page_url }}">Aktuality</a> - </li> - <li> - <a href="{{ page.root_page.candidates_list_page_url }}">Naši lidé</a> - </li> - <li> - <a href="#">Volební program</a> - </li> - <li> - <a href="{{ page.root_page.questions_page_url }}">Časté dotazy</a> - </li> - <li> - <a href="#">Informace o programu</a> - </li> - {% comment %} - <li> - <a href="#">Strategické dokumenty</a> - </li> - <li> - <a href="#">Individuální články</a> - </li> - {% endcomment %} + {% for item in page.root_page.footer_menu %} + <li> + <a href="{% pageurl item.value.page %}">{{ item.value.name }}</a> + </li> + {% endfor %} </ul> </ui-footer-collapsible> </div> @@ -238,6 +220,14 @@ </div> </div> </section> + <section class="footer__sub-links"> + <div class="container container--wide"> + <hr class="hr--condensed" style="border-color: rgb(52, 52, 52);"> + <div class="text-center text-grey-200 pb-4"> + <a href="{{ page.root_page.gdpr_and_cookies_url }}">Zásady zpracování osobních údajů a informace o využití cookies</a> + </div> + </div> + </section> </div> </ui-app> </footer>