From 5964e6f070b4844311720bc5fdecbce14df7b993 Mon Sep 17 00:00:00 2001 From: OndraPetrzilka <ondra.petrzilka@gmail.com> Date: Thu, 25 Aug 2022 06:54:00 +0200 Subject: [PATCH] PeopleOverviewBlock TODO done --- main/blocks.py | 7 ++++--- .../0020_alter_mainhomepage_content.py | 21 +++++++++++++++++++ .../main/blocks/people_overview_block.html | 11 ++++++---- 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 main/migrations/0020_alter_mainhomepage_content.py diff --git a/main/blocks.py b/main/blocks.py index 539ab8e5..1203b039 100644 --- a/main/blocks.py +++ b/main/blocks.py @@ -18,8 +18,8 @@ class CTAMixin(StructBlock): class BoxBlock(CTAMixin, StructBlock): - image = ImageChooserBlock(label="Logo/obrázek") title = CharBlock(label="Nadpis") + image = ImageChooserBlock(label="Logo/obrázek") class BoxesBlock(StructBlock): @@ -71,8 +71,9 @@ class PeopleGroupBlock(StructBlock): return value -class PeopleOverviewBlock(StructBlock): # TODO asi jako BoxesBlock - title = CharBlock(label="Titulek") +class PeopleOverviewBlock(StructBlock): + title = CharBlock(label="Hlavní titulek") + list = ListBlock(BoxBlock, label="Boxíky") class Meta: template = "main/blocks/people_overview_block.html" diff --git a/main/migrations/0020_alter_mainhomepage_content.py b/main/migrations/0020_alter_mainhomepage_content.py new file mode 100644 index 00000000..5c3ffe1d --- /dev/null +++ b/main/migrations/0020_alter_mainhomepage_content.py @@ -0,0 +1,21 @@ +# Generated by Django 4.0.7 on 2022-08-25 04:46 + +from django.db import migrations +import main.blocks +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0019_alter_maincontactpage_text'), + ] + + operations = [ + migrations.AlterField( + model_name='mainhomepage', + name='content', + field=wagtail.fields.StreamField([('carousel', wagtail.blocks.StructBlock([('slides', wagtail.blocks.ListBlock(main.blocks.HomePageCarouseSlideBlock, label='Obrázky s nadpisy - carouselu'))])), ('news', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(help_text='Nejnovější články se načtou automaticky', label='Titulek'))])), ('people', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Hlavní titulek')), ('list', wagtail.blocks.ListBlock(main.blocks.BoxBlock, label='Boxíky'))])), ('regions', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(help_text='Články pro regiony se načtou automaticky', label='Titulek'))])), ('tweets', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(help_text='Tweety budou načteny pro všchny profily uvedené v nastavení webu automaticky', label='Titulek'))])), ('boxes', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Nadpis')), ('list', wagtail.blocks.ListBlock(main.blocks.BoxBlock, label='Boxíky'))]))], blank=True, use_json_field=None, verbose_name='Hlavní obsah'), + ), + ] diff --git a/main/templates/main/blocks/people_overview_block.html b/main/templates/main/blocks/people_overview_block.html index 57ed0ac0..0ff278e7 100644 --- a/main/templates/main/blocks/people_overview_block.html +++ b/main/templates/main/blocks/people_overview_block.html @@ -1,15 +1,18 @@ +{% load wagtailimages_tags %} + <div class="container--medium mb-8 lg:mb-16"> <h2 class="head-7xl text-center mb-6 xl:mb-28"> {{ self.title }} </h2> <div class="flex flex-wrap space-x-1 justify-center items-center"> - {% for box in '1234' %}{# TODO #} + {% for box in self.list %} + {% image box.image fill-500x500 as box_image %} <div class="w-full max-w-xs mb-1 w-80 h-80 flex flex-col items-center justify-center" - style="background-image: url('https://i.picsum.photos/id/261/350/350.jpg?hmac=GOGR4Va2TTfzr3sxRHwTlAxqhpu4M_pl_oKex2O7fcQ')"> + style="background-image: url('{{ box_image.url }}')"> <h5 class="head-alt-md text-white mt-24 mb-8"> - poslanci za piráty + {{ box.title }} </h5> - {% include 'main/includes/button_animated.html' with btn_text="Poslanci" %} + {% include 'main/includes/button_animated.html' with btn_text=box.button_text btn_link=box.button_link %} </div> {% endfor %} </div> -- GitLab