diff --git a/district/blocks.py b/district/blocks.py index d47a310c4e11b1411b2244143997b0cd3666db4b..366440ee84a7992540504a177653822bd5a6981e 100644 --- a/district/blocks.py +++ b/district/blocks.py @@ -19,6 +19,7 @@ from wagtail.images.blocks import ImageChooserBlock from shared.blocks import ( CardLinkBlockMixin, CardLinkWithHeadlineBlockMixin, + PersonContactBlockMixin, ProgramItemBlock, ) @@ -302,7 +303,7 @@ class CardLinkWithHeadlineBlock(CardLinkWithHeadlineBlockMixin): label = "Karty odkazů s nadpisem" -class PersonCustomPositionBlock(StructBlock): +class PersonCustomPositionBlock(PersonContactBlockMixin): position = CharBlock(label="Název pozice", required=False) person = PageChooserBlock( label="Osoba", diff --git a/district/migrations/0144_remove_districthomepage_custom_logo_and_more.py b/district/migrations/0144_remove_districthomepage_custom_logo_and_more.py index 8aa67bf6a8bfe1b1cc2228fc8ba38eb884a817ca..b4b125053a06fc726700796fdfea82e5ca22c01d 100644 --- a/district/migrations/0144_remove_districthomepage_custom_logo_and_more.py +++ b/district/migrations/0144_remove_districthomepage_custom_logo_and_more.py @@ -8,7 +8,7 @@ from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ("district", "0143_remove_districthomepage_show_calendar_on_hp"), + ("district", "0141_alter_districthomepage_content"), ] operations = [ diff --git a/district/migrations/0154_alter_districtarticlespage_options_and_more.py b/district/migrations/0154_alter_districtarticlespage_options_and_more.py index 5b042ae2ff550ff43766739b4b33c8d953b4a5dd..925bb4f4da2549ecf85e1f078627e141fb5469ef 100644 --- a/district/migrations/0154_alter_districtarticlespage_options_and_more.py +++ b/district/migrations/0154_alter_districtarticlespage_options_and_more.py @@ -5,7 +5,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("district", "0153_auto_20240512_1354"), + ("district", "0152_auto_20240512_1336"), ] operations = [ diff --git a/district/migrations/0158_rename_profile_photo_districtpersonpage_main_image.py b/district/migrations/0158_rename_profile_photo_districtpersonpage_main_image.py index edbb6a7e41f8eaa1d47707db4c64b1ceecb7aee3..9ef93f80fdbe9160863029ebf8d81f661d60b8da 100644 --- a/district/migrations/0158_rename_profile_photo_districtpersonpage_main_image.py +++ b/district/migrations/0158_rename_profile_photo_districtpersonpage_main_image.py @@ -1,7 +1,12 @@ # Generated by Django 5.0.4 on 2024-05-13 16:48 +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks from django.db import migrations +import shared.blocks.main + class Migration(migrations.Migration): dependencies = [ @@ -14,4 +19,218 @@ class Migration(migrations.Migration): old_name="profile_photo", new_name="main_image", ), + migrations.AlterField( + model_name="districthomepage", + name="content", + field=wagtail.fields.StreamField( + [ + ( + "fullscreen_header_block", + wagtail.blocks.StructBlock( + [ + ( + "desktop_image", + wagtail.images.blocks.ImageChooserBlock( + help_text="Pokud není vybráno video, ukáže se na desktopu.", + label="Obrázek na pozadí (desktop)", + ), + ), + ( + "mobile_image", + wagtail.images.blocks.ImageChooserBlock( + help_text="Pokud není vybráno video, ukáže se na mobilu.", + label="Obrázek na pozadí (mobil)", + required=False, + ), + ), + ( + "desktop_video_url", + wagtail.blocks.URLBlock( + help_text="Pokud je vybráno, ukáže se na desktopech s povoleným autoplayem místo obrázku.", + label="Video (desktop)", + required=False, + ), + ), + ( + "mobile_video_url", + wagtail.blocks.URLBlock( + help_text="Pokud je vybráno, ukáže se na mobilech s povoleným autoplayem místo obrázku.", + label="Video (mobil)", + required=False, + ), + ), + ( + "desktop_line_1", + wagtail.blocks.TextBlock( + label="Desktop první řádek" + ), + ), + ( + "desktop_line_2", + wagtail.blocks.TextBlock( + label="Desktop druhý řádek", required=False + ), + ), + ( + "mobile_line_1", + wagtail.blocks.TextBlock( + label="První mobilní řádek" + ), + ), + ( + "mobile_line_2", + wagtail.blocks.TextBlock( + label="Druhý mobilní řádek", required=False + ), + ), + ( + "mobile_line_3", + wagtail.blocks.TextBlock( + label="Třetí mobilní řádek", required=False + ), + ), + ( + "button_url", + wagtail.blocks.URLBlock( + help_text="Bez odkazu tlačítko nebude viditelné.", + label="Odkaz tlačítka", + required=False, + ), + ), + ( + "button_text", + wagtail.blocks.CharBlock( + label="Text tlačítka", required=False + ), + ), + ] + ), + ), + ( + "news_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Nejnovější články se načtou automaticky", + label="Titulek", + ), + ), + ( + "description", + wagtail.blocks.TextBlock( + label="Popis", required=False + ), + ), + ], + template="styleguide2/includes/organisms/articles/district/articles_section.html", + ), + ), + ( + "elections_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "text_before_countdown", + wagtail.blocks.CharBlock( + default="Aktuálně zbývá", + label="Text před odpočtem", + required=True, + ), + ), + ( + "countdown_timestamp", + wagtail.blocks.DateTimeBlock( + label="Datum & čas voleb", required=True + ), + ), + ( + "buttons", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", + max_length=128, + required=True, + ), + ), + ( + "page", + wagtail.blocks.PageChooserBlock( + label="Stránka", required=False + ), + ), + ( + "link", + wagtail.blocks.URLBlock( + label="Odkaz", required=False + ), + ), + ] + ), + label="Tlačítka", + required=False, + ), + ), + ] + ), + ), + ( + "people_block", + wagtail.blocks.StructBlock( + [ + ( + "title_line_1", + wagtail.blocks.CharBlock( + label="První řádek titulku" + ), + ), + ( + "title_line_2", + wagtail.blocks.CharBlock( + label="Druhý řádek titulku" + ), + ), + ( + "description", + wagtail.blocks.TextBlock(label="Popis"), + ), + ( + "list", + wagtail.blocks.ListBlock( + shared.blocks.main.BoxBlock, label="Boxíky" + ), + ), + ] + ), + ), + ( + "calendar_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=False + ), + ) + ] + ), + ), + ("newsletter_block", wagtail.blocks.StructBlock([])), + ], + blank=True, + verbose_name="Obsah", + ), + ), ] diff --git a/district/migrations/0161_auto_20240513_1733.py b/district/migrations/0161_auto_20240513_1733.py index 363271e20e21407b558d9a66d9e724c0801539db..e6310b3d465eeded35ce901fdd109588378f6bef 100644 --- a/district/migrations/0161_auto_20240513_1733.py +++ b/district/migrations/0161_auto_20240513_1733.py @@ -29,9 +29,11 @@ def migrate_people_blocks(apps, schema_editor): people = [] for person in old_block["value"]["person_list"]: - person_id = DistrictPersonPage.objects.filter( - id=person["value"]["person"] - ).values_list("id", flat=True).first() + person_id = ( + DistrictPersonPage.objects.filter(id=person["value"]["person"]) + .values_list("id", flat=True) + .first() + ) if person_id is None: continue diff --git a/district/migrations/0162_add_people_block.py b/district/migrations/0162_add_people_block.py new file mode 100644 index 0000000000000000000000000000000000000000..7604a12309690c2636868e4e0a451470652eda23 --- /dev/null +++ b/district/migrations/0162_add_people_block.py @@ -0,0 +1,126 @@ +# Generated by Django 5.0.4 on 2024-05-13 15:33 + +import wagtail +from django.db import migrations + +from district.models import DistrictHomePage, DistrictPeoplePage +from shared.blocks import BoxBlock, PeopleOverviewBlock + + +def add_people_blocks(apps, schema_editor): + # Get the page model + # DistrictPeoplePage = apps.get_model("district", "DistrictPeoplePage") + DistrictPersonPage = apps.get_model("district", "DistrictPersonPage") + # DistrictHomePage = apps.get_model("district", "DistrictHomePage") + + for people_page in DistrictPeoplePage.objects.all(): + people_blocks = people_page.people.get_prep_value() + + person_boxes = [] + home_page = people_page.root_page + + for position, block in enumerate(people_blocks): + title = block["value"]["title"] + slug = block["value"]["slug"] + + people = [] + + person_list_blocks = block["value"]["person_list"] + + for block in person_list_blocks: + people.append( + DistrictPersonPage.objects.filter(id=block["value"]).first() + ) + + if "zastupitel" in title.lower(): + title = "Zastupitelé" + elif ( + "předsednicto" in title.lower() or "předsedové" in title.lower() + ) and ( + "kraj" not in title.lower() + and "místní" not in title.lower() + and "ms" not in title.lower() + and "ks" not in title.lower() + ): + title = "Předsednictvo" + elif "člen" in title.lower(): + title = "Členstvo" + elif ( + "předsednicto" in title.lower() or "předsedové" in title.lower() + ) and ("kraj" in title.lower() or "ks" in title.lower()): + title = "Předsednictvo KS" + elif ( + "předsednicto" in title.lower() or "předsedové" in title.lower() + ) and ("místní" in title.lower() or "ms" in title.lower()): + if "ks" in home_page.title.lower(): + title = "Předsednictva MS" + else: + title = "Předsednictvo MS" + + first_person_page = None + + for person in people: + if not person.profile_image: + continue + + first_person_page = person + break + + if first_person_page is not None: + person_boxes.append( + { + "title": title, + "url": f"{people_page.full_url}?view={slug}-{position + 1}", + "first_person_page": first_person_page, + } + ) + + people_box_blocks = [] + + for person in person_boxes: + people_box_blocks.append( + { + "title": person["title"], + "button_link": person["url"], + "button_text": "Zobrazit osoby", + "image": person["first_person_page"].profile_image.id, + } + ) + + people_overview_block = PeopleOverviewBlock().to_python( + { + "title_line_1": ( + "Lidé v krajském" + if "ks" in home_page.title.lower() + else ( + "Lidé v místním" + if "ms" in home_page.title.lower() + else "Lidé v sdružení" + ) + ), + "title_line_2": ( + "sdružení" + if ( + "ks" in home_page.title.lower() + or "ms" in home_page.title.lower() + ) + else "" + ), + "description": "", + "list": people_box_blocks[:4], + } + ) + + if isinstance(home_page, DistrictHomePage): + home_page.content.append(("people_block", people_overview_block)) + home_page.save() + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0161_auto_20240513_1733"), + ] + + operations = [ + migrations.RunPython(add_people_blocks), + ] diff --git a/district/migrations/0142_auto_20240509_1227.py b/district/migrations/0163_auto_20240509_1227.py similarity index 93% rename from district/migrations/0142_auto_20240509_1227.py rename to district/migrations/0163_auto_20240509_1227.py index 10dcb73e893d5dcda17218fe5beaf41d4d0b0bc4..dfd22c07c17d273a4d7e7dd3b44d1a586d35825b 100644 --- a/district/migrations/0142_auto_20240509_1227.py +++ b/district/migrations/0163_auto_20240509_1227.py @@ -27,7 +27,7 @@ def add_calendar_block(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("district", "0141_alter_districthomepage_content"), + ("district", "0162_add_people_block"), ] operations = [migrations.RunPython(add_calendar_block)] diff --git a/district/migrations/0153_auto_20240512_1354.py b/district/migrations/0164_auto_20240512_1354.py similarity index 92% rename from district/migrations/0153_auto_20240512_1354.py rename to district/migrations/0164_auto_20240512_1354.py index 05193eaf437324d9d3726d5fac00a4141dfa6a18..a9152a285c46493efb476b42b8336d1c8a39518c 100644 --- a/district/migrations/0153_auto_20240512_1354.py +++ b/district/migrations/0164_auto_20240512_1354.py @@ -19,7 +19,7 @@ def add_newsletter_blocks(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("district", "0152_auto_20240512_1336"), + ("district", "0163_auto_20240509_1227"), ] operations = [migrations.RunPython(add_newsletter_blocks)] diff --git a/district/migrations/0143_remove_districthomepage_show_calendar_on_hp.py b/district/migrations/0165_remove_districthomepage_show_calendar_on_hp.py similarity index 86% rename from district/migrations/0143_remove_districthomepage_show_calendar_on_hp.py rename to district/migrations/0165_remove_districthomepage_show_calendar_on_hp.py index 448589f77b6198f5675978dc2cb1024563f65aac..3bd4faf8031f322a9961c26d8b9634f2f4387f82 100644 --- a/district/migrations/0143_remove_districthomepage_show_calendar_on_hp.py +++ b/district/migrations/0165_remove_districthomepage_show_calendar_on_hp.py @@ -5,7 +5,7 @@ from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ("district", "0142_auto_20240509_1227"), + ("district", "0164_auto_20240512_1354"), ] operations = [ diff --git a/district/migrations/0166_alter_districthomepage_content.py b/district/migrations/0166_alter_districthomepage_content.py new file mode 100644 index 0000000000000000000000000000000000000000..83985a254d9f3ad5bb8901322150b9d6af2dad8a --- /dev/null +++ b/district/migrations/0166_alter_districthomepage_content.py @@ -0,0 +1,232 @@ +# Generated by Django 5.0.4 on 2024-05-14 10:36 + +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations + +import shared.blocks.main + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0165_remove_districthomepage_show_calendar_on_hp"), + ] + + operations = [ + migrations.AlterField( + model_name="districthomepage", + name="content", + field=wagtail.fields.StreamField( + [ + ( + "fullscreen_header_block", + wagtail.blocks.StructBlock( + [ + ( + "desktop_image", + wagtail.images.blocks.ImageChooserBlock( + help_text="Pokud není vybráno video, ukáže se na desktopu.", + label="Obrázek na pozadí (desktop)", + ), + ), + ( + "mobile_image", + wagtail.images.blocks.ImageChooserBlock( + help_text="Pokud není vybráno video, ukáže se na mobilu.", + label="Obrázek na pozadí (mobil)", + required=False, + ), + ), + ( + "desktop_video_url", + wagtail.blocks.URLBlock( + help_text="Pokud je vybráno, ukáže se na desktopech s povoleným autoplayem místo obrázku.", + label="Video (desktop)", + required=False, + ), + ), + ( + "mobile_video_url", + wagtail.blocks.URLBlock( + help_text="Pokud je vybráno, ukáže se na mobilech s povoleným autoplayem místo obrázku.", + label="Video (mobil)", + required=False, + ), + ), + ( + "desktop_line_1", + wagtail.blocks.TextBlock( + label="Desktop první řádek" + ), + ), + ( + "desktop_line_2", + wagtail.blocks.TextBlock( + label="Desktop druhý řádek", required=False + ), + ), + ( + "mobile_line_1", + wagtail.blocks.TextBlock( + label="První mobilní řádek" + ), + ), + ( + "mobile_line_2", + wagtail.blocks.TextBlock( + label="Druhý mobilní řádek", required=False + ), + ), + ( + "mobile_line_3", + wagtail.blocks.TextBlock( + label="Třetí mobilní řádek", required=False + ), + ), + ( + "button_url", + wagtail.blocks.URLBlock( + help_text="Bez odkazu tlačítko nebude viditelné.", + label="Odkaz tlačítka", + required=False, + ), + ), + ( + "button_text", + wagtail.blocks.CharBlock( + label="Text tlačítka", required=False + ), + ), + ] + ), + ), + ( + "news_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + help_text="Nejnovější články se načtou automaticky", + label="Titulek", + ), + ), + ( + "description", + wagtail.blocks.TextBlock( + label="Popis", required=False + ), + ), + ], + template="styleguide2/includes/organisms/articles/district/articles_section.html", + ), + ), + ( + "elections_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "text_before_countdown", + wagtail.blocks.CharBlock( + default="Aktuálně zbývá", + label="Text před odpočtem", + required=True, + ), + ), + ( + "countdown_timestamp", + wagtail.blocks.DateTimeBlock( + label="Datum & čas voleb", required=True + ), + ), + ( + "buttons", + wagtail.blocks.ListBlock( + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", + max_length=128, + required=True, + ), + ), + ( + "page", + wagtail.blocks.PageChooserBlock( + label="Stránka", required=False + ), + ), + ( + "link", + wagtail.blocks.URLBlock( + label="Odkaz", required=False + ), + ), + ] + ), + label="Tlačítka", + required=False, + ), + ), + ] + ), + ), + ( + "people_block", + wagtail.blocks.StructBlock( + [ + ( + "title_line_1", + wagtail.blocks.CharBlock( + label="První řádek titulku" + ), + ), + ( + "title_line_2", + wagtail.blocks.CharBlock( + label="Druhý řádek titulku" + ), + ), + ( + "description", + wagtail.blocks.TextBlock(label="Popis"), + ), + ( + "list", + wagtail.blocks.ListBlock( + shared.blocks.main.BoxBlock, label="Boxíky" + ), + ), + ], + template="styleguide2/includes/organisms/main_section/district/representatives_section.html", + ), + ), + ( + "calendar_block", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=False + ), + ) + ] + ), + ), + ("newsletter_block", wagtail.blocks.StructBlock([])), + ], + blank=True, + verbose_name="Obsah", + ), + ), + ] diff --git a/district/migrations/0167_alter_districtcontactpage_contact_people.py b/district/migrations/0167_alter_districtcontactpage_contact_people.py new file mode 100644 index 0000000000000000000000000000000000000000..139f7795f9b52a976d34fda2997ebcb6531fa7dd --- /dev/null +++ b/district/migrations/0167_alter_districtcontactpage_contact_people.py @@ -0,0 +1,43 @@ +# Generated by Django 5.0.4 on 2024-05-14 11:15 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0166_alter_districthomepage_content"), + ] + + operations = [ + migrations.AlterField( + model_name="districtcontactpage", + name="contact_people", + field=wagtail.fields.StreamField( + [ + ( + "item", + wagtail.blocks.StructBlock( + [ + ( + "position", + wagtail.blocks.CharBlock( + label="Název pozice", required=False + ), + ), + ( + "person", + wagtail.blocks.PageChooserBlock( + label="Osoba", page_type=["main.MainPersonPage"] + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Kontakty", + ), + ), + ] diff --git a/district/migrations/0168_districtcontactpage_contact_boxes.py b/district/migrations/0168_districtcontactpage_contact_boxes.py new file mode 100644 index 0000000000000000000000000000000000000000..cb2dd724f378f5683aa8a277efb49e5b7b687bf1 --- /dev/null +++ b/district/migrations/0168_districtcontactpage_contact_boxes.py @@ -0,0 +1,43 @@ +# Generated by Django 5.0.4 on 2024-05-14 11:15 + +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0167_alter_districtcontactpage_contact_people"), + ] + + operations = [ + migrations.AddField( + model_name="districtcontactpage", + name="contact_boxes", + field=wagtail.fields.StreamField( + [ + ( + "item", + wagtail.blocks.StructBlock( + [ + ("title", wagtail.blocks.CharBlock(label="Titulek")), + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + label="Ikona" + ), + ), + ( + "subtitle", + wagtail.blocks.CharBlock(label="Podtitulek"), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Kontaktní boxy", + ), + ), + ] diff --git a/district/migrations/0169_alter_districtcontactpage_contact_people_and_more.py b/district/migrations/0169_alter_districtcontactpage_contact_people_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..110f9409a17f0e015212534db9950bd6ebd1adfa --- /dev/null +++ b/district/migrations/0169_alter_districtcontactpage_contact_people_and_more.py @@ -0,0 +1,74 @@ +# Generated by Django 5.0.4 on 2024-05-14 11:31 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("district", "0168_districtcontactpage_contact_boxes"), + ] + + operations = [ + migrations.AlterField( + model_name="districtcontactpage", + name="contact_people", + field=wagtail.fields.StreamField( + [ + ( + "item", + wagtail.blocks.StructBlock( + [ + ( + "position", + wagtail.blocks.CharBlock( + label="Název pozice", required=False + ), + ), + ( + "person", + wagtail.blocks.PageChooserBlock( + label="Osoba", + page_type=["district.DistrictPersonPage"], + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Kontaktní osoby", + ), + ), + migrations.AlterField( + model_name="districthomepage", + name="footer_person_list", + field=wagtail.fields.StreamField( + [ + ( + "person", + wagtail.blocks.StructBlock( + [ + ( + "position", + wagtail.blocks.CharBlock( + label="Název pozice", required=False + ), + ), + ( + "person", + wagtail.blocks.PageChooserBlock( + label="Osoba", + page_type=["district.DistrictPersonPage"], + ), + ), + ] + ), + ) + ], + blank=True, + verbose_name="Osoby v zápatí webu", + ), + ), + ] diff --git a/district/models.py b/district/models.py index b1cb65ef25fceedb2fd52ada29090ef7ccd71ff7..c43691ba2dd897bac840cc33fd7f7320008d5d3d 100644 --- a/district/models.py +++ b/district/models.py @@ -46,6 +46,7 @@ from shared.blocks import ( NavbarMenuItemBlock, NewsBlock, NewsletterSubscriptionBlock, + PeopleOverviewBlock, YouTubeVideoBlock, ) from shared.const import RICH_TEXT_DEFAULT_FEATURES @@ -58,6 +59,7 @@ from shared.models import ( FooterMixin, MainArticlePageMixin, MainArticlesPageMixin, + MainContactPageMixin, MainFooterMixin, MainMenuMixin, MainPeoplePageMixin, @@ -105,6 +107,12 @@ class DistrictHomePage( ), ), ("elections_block", blocks.ElectionsCountdownBlock()), + ( + "people_block", + PeopleOverviewBlock( + template="styleguide2/includes/organisms/main_section/district/representatives_section.html" + ), + ), ("calendar_block", blocks.CalendarBlock()), ("newsletter_block", blocks.NewsletterBlock()), ], @@ -113,6 +121,15 @@ class DistrictHomePage( use_json_field=True, ) + # footer + footer_person_list = StreamField( + [("person", blocks.PersonCustomPositionBlock())], + verbose_name="Osoby v zápatí webu", + blank=True, + max_num=6, + use_json_field=True, + ) + menu_button_name = models.CharField( verbose_name="Text na tlačítku pro zapojení", max_length=16 ) @@ -157,17 +174,6 @@ class DistrictHomePage( default="Fake news tam nenajdeš, ale dozvíš se, co chystáme doopravdy!", ) - # Lide uvedeni v paticce - footer_person_list = StreamField( - [ - ("footer_person_list", blocks.PersonCustomPositionBlock()), - ], - verbose_name="Osoby v zápatí webu", - blank=True, - max_num=6, - use_json_field=True, - ) - # Extra komentar v paticce footer_extra_content = RichTextField( verbose_name="Extra obsah na začátku patičky", @@ -411,29 +417,17 @@ class DistrictArticlesPage(MainArticlesPageMixin): subpage_types = ["district.DistrictArticlePage"] -class DistrictContactPage( - ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, Page -): +class DistrictContactPage(MainContactPageMixin): ### FIELDS + text = RichTextField("Text", blank=True, features=RICH_TEXT_DEFAULT_FEATURES) + contact_people = StreamField( [("item", blocks.PersonCustomPositionBlock())], - verbose_name="Kontakty", + verbose_name="Kontaktní osoby", blank=True, use_json_field=True, ) - text = RichTextField("Text", blank=True, features=RICH_TEXT_DEFAULT_FEATURES) - - ### PANELS - - content_panels = Page.content_panels + [ - FieldPanel("contact_people"), - FieldPanel("text"), - ] - - promote_panels = make_promote_panels() - - settings_panels = [] ### RELATIONS diff --git a/district/templates/district/district_contact_page.html b/district/templates/district/district_contact_page.html index 97432add429f161d529df9e391c724ae2394faa0..268e3bed634ec25ae6d78857681ff41bc9776c3a 100644 --- a/district/templates/district/district_contact_page.html +++ b/district/templates/district/district_contact_page.html @@ -1,102 +1 @@ -{% extends "district/base.html" %} -{% load wagtailcore_tags wagtailimages_tags shared_filters %} - -{% block container_spacing %}pt-8 pb-0 lg:py-16{% endblock %} - -{% block content %} - <div class="lg:flex space-y-8 lg:space-y-0 lg:space-x-8 xl:space-x-16 mb-8 lg:mb-16"> - <section class="lg:w-3/5 xl:w-2/3"> - <header> - <h1 itemprop="headline" class="head-alt-md md:head-alt-lg max-w-5xl mb-8">{{ page.title }}</h1> - </header> - - <div class="space-y-8"> - <div class="content-block"> - {{ page.text | richtext }} - </div> - - {% for item in page.contact_people %} - <div> - {% if item.value.position %} - <h2 class="head-heavy-sm mb-2 lg:mb-4"> - {{ item.value.position }} - </h2> - {% elif item.value.person.job_function %} - <h2 class="head-heavy-sm mb-2 lg:mb-4"> - {{ item.value.person.job_function }} - </h2> - {% endif %} - <div class="card elevation-3"> - <div class="card__body"> - {% include "shared/person_badge_wide_snippet.html" with person_page=item.value.person %} - </div> - </div> - </div> - {% endfor %} - </div> - </section> - - <section class="lg:w-2/5 xl:w-1/3"> - <div class="lg:card lg:elevation-10"> - <div class="lg:card__body content-block"> - - <h2>Základní údaje</h2> - - <div class="space-y-4"> - {% if page.root_page.contact_email %} - <div> - <h4>Emailová adresa</h4> - <a href="mailto:{{ page.root_page.contact_email }}" class="contact-line icon-link content-block--nostyle "> - <i class="ico--envelope"></i><span>{{ page.root_page.contact_email }}</span> - </a> - </div> - {% endif %} - - {% if page.root_page.contact_email %} - <div> - <h4>Telefonický kontakt</h4> - <a href="tel:{{ page.root_page.contact_phone }}" class="contact-line icon-link content-block--nostyle "> - <i class="ico--phone"></i><span>{{ page.root_page.contact_phone }}</span> - </a> - </div> - {% endif %} - - <div> - <h4>Transparentní účty</h4> - 2100048174/2010 a <a href="https://wiki.pirati.cz/fo/seznam_uctu">další účty</a> - </div> - - <div> - <h4>Datová schránka</h4> - <span class="contact-line icon-link content-block--nostyle "> - <i class="ico--drawer"></i><span>b2i4r6j</span></span> - </div> - - <div> - <h4>Celostátní web</h4> - <a href="https://pirati.cz" class="contact-line icon-link content-block--nostyle "> - <i class="ico--pirati"></i><span>pirati.cz</span> - </a> - </div> - - <p>Každý člen strany má email ve tvaru: <tt>jmeno.prijmeni@pirati.cz</tt></p> - </div> - - {% comment %} <hr class="hr"> {% endcomment %} -{##} -{# <h2>Sídlo a kontaktní centrum</h2> FIXME #} -{# <strong>Piráti Zlínský kraj</strong>#} - - </div> - </div> - </section> - </div> - - {% if page.root_page.newsletter_info %} - <section class="my-8 lg:my-24 container-padding--zero lg:container-padding--auto"> - {% include "shared/blocks/newsletter_subscription_block.html" with value=page.root_page.newsletter_info %} - </section> - {% endif%} - - {% include "shared/followus_snippet.html" %} -{% endblock %} +{% extends "styleguide2/contact_page.html" %} diff --git a/elections/migrations/0029_alter_electionshomepage_footer_person_list.py b/elections/migrations/0029_alter_electionshomepage_footer_person_list.py new file mode 100644 index 0000000000000000000000000000000000000000..25f14a5e387ae7a107ee37a2bfb37b5b8cb885b8 --- /dev/null +++ b/elections/migrations/0029_alter_electionshomepage_footer_person_list.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.4 on 2024-05-14 11:25 + +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("elections", "0028_alter_electionshomepage_footer_other_links"), + ] + + operations = [ + migrations.AlterField( + model_name="electionshomepage", + name="footer_person_list", + field=wagtail.fields.StreamField( + [], blank=True, verbose_name="Osoby v zápatí webu" + ), + ), + ] diff --git a/elections/templates/elections/elections_contact_page.html b/elections/templates/elections/elections_contact_page.html index 268e3bed634ec25ae6d78857681ff41bc9776c3a..00b3d628792173dc4f484cdb2dd2ea48b68bfdd1 100644 --- a/elections/templates/elections/elections_contact_page.html +++ b/elections/templates/elections/elections_contact_page.html @@ -1 +1 @@ -{% extends "styleguide2/contact_page.html" %} +{% extends "styleguide2/contact_page.html" with show_regional_contacts=True %} diff --git a/main/blocks.py b/main/blocks.py index ef5f376b405194960ced18e3c80108f3c740ba14..2c3509dfe41a60b42b096ca72a46ccda9b63068e 100644 --- a/main/blocks.py +++ b/main/blocks.py @@ -13,9 +13,11 @@ from wagtail.images.blocks import ImageChooserBlock from shared.blocks import ( PROGRAM_RICH_TEXT_FEATURES, + BoxBlock, CardLinkBlockMixin, CardLinkWithHeadlineBlockMixin, CTAMixin, + PersonContactBlockMixin, ) from shared.blocks import ProgramGroupBlockPopout as SharedProgramGroupBlockPopout @@ -56,15 +58,6 @@ class ProgramGroupBlockMixin(StructBlock): return value -class BoxBlock(CTAMixin, StructBlock): - title = CharBlock(label="Nadpis") - image = ImageChooserBlock(label="Logo/obrázek") - - class Meta: - icon = "form" - label = "Box" - - class BoxesBlock(StructBlock): title = CharBlock(label="Nadpis") list = ListBlock(BoxBlock, label="Boxíky") @@ -135,22 +128,6 @@ class PeopleGroupBlock(StructBlock): return value -class PeopleOverviewBlock(StructBlock): - title_line_1 = CharBlock(label="První řádek titulku") - title_line_2 = CharBlock(label="Druhý řádek titulku") - - description = TextBlock(label="Popis") - - list = ListBlock(BoxBlock, label="Boxíky") - - class Meta: - template = ( - "styleguide2/includes/organisms/main_section/representatives_section.html" - ) - icon = "group" - label = "Skupina osob" - - class ProgramBlock(StructBlock): url = URLBlock( label="Odkaz pokrývající celou tuto část", @@ -296,6 +273,13 @@ class ProgramGroupBlockPopout(SharedProgramGroupBlockPopout, ProgramGroupBlockMi pass +class PersonContactBlock(PersonContactBlockMixin): + person = PageChooserBlock( + label="Osoba", + page_type=["main.MainPersonPage"], + ) + + # --- TODO: Remove legacy blocks used in migrations only diff --git a/main/models.py b/main/models.py index 728c9e676c515c4310cf71dd62cbc050e304c373..2990227eefe166a4b7e22c5677e682cd38777f1c 100644 --- a/main/models.py +++ b/main/models.py @@ -64,7 +64,7 @@ class MainHomePage(MainHomePageMixin): ), ), # ("europarl_news", blocks.EuroparlNewsBlock()), - ("people", blocks.PeopleOverviewBlock()), + ("people", shared_blocks.PeopleOverviewBlock()), ("regions", blocks.RegionsBlock()), ("boxes", blocks.BoxesBlock()), ], @@ -72,6 +72,16 @@ class MainHomePage(MainHomePageMixin): blank=True, use_json_field=True, ) + + # footer + footer_person_list = StreamField( + [("person", blocks.PersonContactBlock())], + verbose_name="Osoby v zápatí webu", + blank=True, + max_num=6, + use_json_field=True, + ) + # settings gdpr_and_cookies_page = models.ForeignKey( "main.MainSimplePage", @@ -350,6 +360,15 @@ class MainSimplePage(MainSimplePageMixin): class MainContactPage(MainContactPageMixin): + ### FIELDS + + contact_people = StreamField( + [("item", blocks.PersonContactBlock())], + verbose_name="Kontaktní osoby", + blank=True, + use_json_field=True, + ) + ### RELATIONS parent_page_types = ["main.MainHomePage"] diff --git a/main/templates/main/main_contact_page.html b/main/templates/main/main_contact_page.html index 268e3bed634ec25ae6d78857681ff41bc9776c3a..00b3d628792173dc4f484cdb2dd2ea48b68bfdd1 100644 --- a/main/templates/main/main_contact_page.html +++ b/main/templates/main/main_contact_page.html @@ -1 +1 @@ -{% extends "styleguide2/contact_page.html" %} +{% extends "styleguide2/contact_page.html" with show_regional_contacts=True %} diff --git a/shared/blocks/main.py b/shared/blocks/main.py index a2e0c3fcedc8ca70beee0c2ecc9068376de440c3..f67ff1747701ba739fc62ec4a0b7db0a28834fca 100644 --- a/shared/blocks/main.py +++ b/shared/blocks/main.py @@ -142,15 +142,12 @@ class PersonContactBoxBlock(StructBlock): label = "Kontakty" -class PersonContactBlock(StructBlock): +class PersonContactBlockMixin(StructBlock): position = CharBlock(label="Název pozice", required=False) # email, phone? - person = PageChooserBlock( - label="Osoba", - page_type=["main.MainPersonPage"], - ) class Meta: + abstract = True icon = "user" label = "Osoba s volitelnou pozicí" @@ -233,3 +230,28 @@ class FlipCardsBlock(StructBlock): icon = "group" label = "Seznam obracecích karet" template = "styleguide2/includes/organisms/cards/flip_card_list.html" + + +class BoxBlock(CTAMixin, StructBlock): + title = CharBlock(label="Nadpis") + image = ImageChooserBlock(label="Logo/obrázek") + + class Meta: + icon = "form" + label = "Box" + + +class PeopleOverviewBlock(StructBlock): + title_line_1 = CharBlock(label="První řádek titulku") + title_line_2 = CharBlock(label="Druhý řádek titulku") + + description = TextBlock(label="Popis") + + list = ListBlock(BoxBlock, label="Boxíky") + + class Meta: + template = ( + "styleguide2/includes/organisms/main_section/representatives_section.html" + ) + icon = "group" + label = "Skupina osob" diff --git a/shared/models/main.py b/shared/models/main.py index 700768ab0f6ba755a7811bbdd97c0b81228b3159..d05dd21d0096f5152b4a5a622c909f2336ec693c 100644 --- a/shared/models/main.py +++ b/shared/models/main.py @@ -35,7 +35,6 @@ from shared.blocks import ( MainMenuItemBlock, NavbarMenuItemBlock, OtherLinksBlock, - PersonContactBlock, PersonContactBoxBlock, SocialLinkBlock, TwoTextColumnBlock, @@ -190,8 +189,9 @@ class MainHomePageMixin( ) # footer + # NOTE: Needs to be oberriden footer_person_list = StreamField( - [("person", PersonContactBlock())], + [], verbose_name="Osoby v zápatí webu", blank=True, max_num=6, @@ -678,7 +678,7 @@ class MainContactPageMixin( ### FIELDS contact_people = StreamField( - [("item", PersonContactBlock())], + [], verbose_name="Kontaktní osoby", blank=True, use_json_field=True, diff --git a/shared/templates/styleguide2/contact_page.html b/shared/templates/styleguide2/contact_page.html index dd8ecadaca3997da0bf390da5fc7ec552a64ecdb..5f530b6ce1dd2fdcfb66f709df313277ed9325b0 100644 --- a/shared/templates/styleguide2/contact_page.html +++ b/shared/templates/styleguide2/contact_page.html @@ -30,15 +30,17 @@ </div> </div> - <div class="w-full max-w-2xl"> - <h2 class="head-6xl mb-5"> - Regionální kontakty - </h2> + {% if show_regional_contacts %} + <div class="w-full max-w-2xl"> + <h2 class="head-6xl mb-5"> + Regionální kontakty + </h2> - <div class="__js-root w-full flex max-w-2xl items-center"> - <ui-region-map class="w-full"></ui-region-map> + <div class="__js-root w-full flex max-w-2xl items-center"> + <ui-region-map class="w-full"></ui-region-map> + </div> </div> - </div> + {% endif %} </div> </div> diff --git a/shared/templates/styleguide2/includes/molecules/boxes/image_with_button_box.html b/shared/templates/styleguide2/includes/molecules/boxes/image_with_button_box.html index 01056d8deac8ad3fd5779aa1f7b50198d0d34007..0b79e4863bccc5c154f7f9fc38b2e18fe4f61c77 100644 --- a/shared/templates/styleguide2/includes/molecules/boxes/image_with_button_box.html +++ b/shared/templates/styleguide2/includes/molecules/boxes/image_with_button_box.html @@ -8,7 +8,7 @@ <h2 class="head-6xl">{{ title }}</h2> </div> - <div class="text-center flex justify-center"> + <div class="text-center flex justify-center mt-auto"> {% include 'styleguide2/includes/atoms/buttons/round_button.html' with url=url classes='bg-white text-black' button_text=button_text %} </div> </div> diff --git a/shared/templates/styleguide2/includes/organisms/main_section/representatives_section.html b/shared/templates/styleguide2/includes/organisms/main_section/representatives_section.html index 41fb7967a68787d4ac5863454d8713ff698c0a04..efa2f635bd009da6ff9069ecde8d2a95fd867cbf 100644 --- a/shared/templates/styleguide2/includes/organisms/main_section/representatives_section.html +++ b/shared/templates/styleguide2/includes/organisms/main_section/representatives_section.html @@ -1,6 +1,6 @@ {% load wagtailimages_tags %} -<div class="bg-black text-white"> +<div class="{% block wrapper_classes %}bg-black text-white{% endblock %}"> <div class="container--medium __js-root"> <!-- NOTE: This will change once europarl section exists. py-16 xl:py-24 -->