From 2ec2ac1a254f612befa55b80a4a3c799f2f5edab Mon Sep 17 00:00:00 2001 From: "jindra12.underdark" <jindra12.underdark@gmail.com> Date: Mon, 1 May 2023 17:27:07 +0200 Subject: [PATCH] Add optional black below-footer content #162 --- ...0_districthomepage_footer_extra_content.py | 20 ++++++++++++++ district/models.py | 13 ++++++++++ district/templates/district/base.html | 17 +++++++----- ...atcampaignhomepage_footer_extra_content.py | 20 ++++++++++++++ senat_campaign/models.py | 4 +++ .../templates/senat_campaign/base.html | 26 ++++++++++++++----- ...042_uniwebhomepage_footer_extra_content.py | 20 ++++++++++++++ uniweb/models.py | 10 ++++++- uniweb/templates/uniweb/base.html | 9 +++++++ 9 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 district/migrations/0110_districthomepage_footer_extra_content.py create mode 100644 senat_campaign/migrations/0011_senatcampaignhomepage_footer_extra_content.py create mode 100644 uniweb/migrations/0042_uniwebhomepage_footer_extra_content.py diff --git a/district/migrations/0110_districthomepage_footer_extra_content.py b/district/migrations/0110_districthomepage_footer_extra_content.py new file mode 100644 index 00000000..c302198a --- /dev/null +++ b/district/migrations/0110_districthomepage_footer_extra_content.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.8 on 2023-05-01 14:58 + +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0109_alter_districthomepage_subheader"), + ] + + operations = [ + migrations.AddField( + model_name="districthomepage", + name="footer_extra_content", + field=wagtail.fields.RichTextField( + blank=True, verbose_name="Extra obsah pod šedou patičkou" + ), + ), + ] diff --git a/district/models.py b/district/models.py index 06886775..0f091633 100644 --- a/district/models.py +++ b/district/models.py @@ -188,6 +188,13 @@ class DistrictHomePage( use_json_field=True, ) + # Extra komentar v paticce + footer_extra_content = RichTextField( + verbose_name="Extra obsah pod šedou patičkou", + blank=True, + features=RICH_TEXT_DEFAULT_FEATURES, + ) + # settings matomo_id = models.IntegerField( "Matomo ID pro sledování návštěvnosti", blank=True, null=True @@ -244,6 +251,12 @@ class DistrictHomePage( ], gettext_lazy("Lidé v zápatí stránky"), ), + MultiFieldPanel( + [ + FieldPanel("footer_extra_content"), + ], + gettext_lazy("Extra obsah v patičce"), + ), MultiFieldPanel( [ FieldPanel("region_map_button_text"), diff --git a/district/templates/district/base.html b/district/templates/district/base.html index 0f20b30b..360bdcf8 100644 --- a/district/templates/district/base.html +++ b/district/templates/district/base.html @@ -322,14 +322,19 @@ </section> </div> - {% if page.root_page.footer_person_list %} + {% if page.root_page.footer_person_list or page.root_page.footer_extra_content %} <section class="bg-black py-4 lg:py-12"> <div class="container container--default"> - <div class="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3"> - {% for person_block in page.root_page.footer_person_list %} - {% include "shared/person_badge_snippet.html" with person_page=person_block.value.person title=person_block.value.position %} - {% endfor %} - </div> + <div class="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3"> + {% if page.root_page.footer_person_list %} + {% for person_block in page.root_page.footer_person_list %} + {% include "shared/person_badge_snippet.html" with person_page=person_block.value.person title=person_block.value.position %} + {% endfor %} + {% endif %} + {% if page.root_page.footer_extra_content %} + {{ page.root_page.footer_extra_content|richtext }} + {% endif %} + </div> </div> </section> {% endif %} diff --git a/senat_campaign/migrations/0011_senatcampaignhomepage_footer_extra_content.py b/senat_campaign/migrations/0011_senatcampaignhomepage_footer_extra_content.py new file mode 100644 index 00000000..45db68dc --- /dev/null +++ b/senat_campaign/migrations/0011_senatcampaignhomepage_footer_extra_content.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.8 on 2023-05-01 15:14 + +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("senat_campaign", "0010_alter_senatcampaignhomepage_about_gallery_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="senatcampaignhomepage", + name="footer_extra_content", + field=wagtail.fields.RichTextField( + blank=True, verbose_name="Extra obsah pod šedou patičkou" + ), + ), + ] diff --git a/senat_campaign/models.py b/senat_campaign/models.py index 7b68f070..98556d4e 100644 --- a/senat_campaign/models.py +++ b/senat_campaign/models.py @@ -124,6 +124,9 @@ class SenatCampaignHomePage( matomo_id = models.IntegerField( "Matomo ID pro sledování návštěvnosti", blank=True, null=True ) + footer_extra_content = RichTextField( + verbose_name="Extra obsah pod šedou patičkou", blank=True + ) ### PANELS @@ -188,6 +191,7 @@ class SenatCampaignHomePage( FieldPanel("matomo_id"), FieldPanel("title_suffix"), FieldPanel("contacts"), + FieldPanel("footer_extra_content"), CommentPanel(), ] diff --git a/senat_campaign/templates/senat_campaign/base.html b/senat_campaign/templates/senat_campaign/base.html index 12f90ae5..8408af06 100644 --- a/senat_campaign/templates/senat_campaign/base.html +++ b/senat_campaign/templates/senat_campaign/base.html @@ -201,12 +201,26 @@ <div class="footer__bottom"> <div class="container"> <div class="row"> - <div class="col-12 col-md-6 mb-3 mb-md-0"> - <p class="mb-0">{% now "Y" %} | Zadavatel: {{ page.root_page.full_name }} | Zpracovatel: Česká pirátská strana</p> - </div><!-- /column --> - <div class="col-12 col-md-6 text-md-right"> - <p class="mb-0">Tento web využívá soubory cookies - <a href="{{ page.root_page.cookies_page_url }}">více informací</a></p> - </div><!-- /column --> + {% if page.root_page.footer_extra_content %} + <div class="col-12 col-md-5 mb-3 mb-md-0"> + <p class="mb-0">{% now "Y" %} | Zadavatel: {{ page.root_page.full_name }} | Zpracovatel: Česká pirátská strana</p> + </div><!-- /column --> + <div class="col-12 col-md-3"> + <p class="mb-0"> + {{ page.root_page.footer_extra_content|richtext }} + </p> + </div> + <div class="col-12 col-md-4 text-md-right"> + <p class="mb-0">Tento web využívá soubory cookies - <a href="{{ page.root_page.cookies_page_url }}">více informací</a></p> + </div><!-- /column --> + {% else %} + <div class="col-12 col-md-6 mb-3 mb-md-0"> + <p class="mb-0">{% now "Y" %} | Zadavatel: {{ page.root_page.full_name }} | Zpracovatel: Česká pirátská strana</p> + </div><!-- /column --> + <div class="col-12 col-md-6 text-md-right"> + <p class="mb-0">Tento web využívá soubory cookies - <a href="{{ page.root_page.cookies_page_url }}">více informací</a></p> + </div><!-- /column --> + {% endif %} </div><!-- /row --> </div><!-- /container --> </div><!-- /footer_bottom --> diff --git a/uniweb/migrations/0042_uniwebhomepage_footer_extra_content.py b/uniweb/migrations/0042_uniwebhomepage_footer_extra_content.py new file mode 100644 index 00000000..aa366e33 --- /dev/null +++ b/uniweb/migrations/0042_uniwebhomepage_footer_extra_content.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.8 on 2023-05-01 15:23 + +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_extra_content", + field=wagtail.fields.RichTextField( + blank=True, verbose_name="Extra obsah pod šedou patičkou" + ), + ), + ] diff --git a/uniweb/models.py b/uniweb/models.py index 42389c9d..70f746cb 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -1,3 +1,5 @@ +import random + from captcha.fields import CaptchaField from django import forms from django.core.paginator import Paginator @@ -31,7 +33,7 @@ from shared.models import ( ExtendedMetadataPageMixin, SubpageMixin, ) -from shared.utils import make_promote_panels +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 @@ -339,6 +341,11 @@ class UniwebHomePage( default=True, help_text="Zobrazit pirátská tlačítka", ) + footer_extra_content = RichTextField( + verbose_name="Extra obsah pod šedou patičkou", + blank=True, + features=RICH_TEXT_DEFAULT_FEATURES, + ) ### PANELS @@ -361,6 +368,7 @@ class UniwebHomePage( FieldPanel("show_logo"), FieldPanel("show_social_links"), FieldPanel("show_pirate_buttons"), + FieldPanel("footer_extra_content"), ], "nastavení patičky", ), diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index 7f179853..733e7c91 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -136,6 +136,15 @@ </div> </div> </ui-app> + {% if page.root_page.footer_extra_content %} + <section class="bg-black py-4 lg:py-12"> + <div class="container container--default"> + <div class="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3"> + {{ page.root_page.footer_extra_content|richtext }} + </div> + </div> + </section> + {% endif %} </footer> <script src="{% static "shared/vendor/vue/vue.2.6.11.js" %}"></script> -- GitLab