Skip to content
Snippets Groups Projects
Verified Commit 93a64e29 authored by Alexa Valentová's avatar Alexa Valentová
Browse files

elections program on main page, allow missing icons, fix news anchor, add...

elections program on main page, allow missing icons, fix news anchor, add description to program popout category
parent 28694aa2
No related branches found
No related tags found
2 merge requests!951elections program on main page, allow missing icons, fix news anchor, add...,!949Elections program on main page, allow missing icons, fix news anchor, add description to program popout category
Pipeline #17414 passed
......@@ -6,6 +6,7 @@ from django.db import models
from django.forms.models import model_to_dict
from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import redirect, render
from django.template.loader import render_to_string
from django.utils import timezone
from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey
......@@ -360,3 +361,14 @@ class ElectionsFullProgramPage(
class Meta:
verbose_name = "Celá verze programu"
## OTHERS
def get_main_page_program_render(self):
for block in self.content:
if block.block_type == "popout_block":
return render_to_string(
"styleguide2/includes/organisms/popouts/popout_list.html",
{"categories": block.value["categories"]},
)
return ""
......@@ -310,7 +310,23 @@ class FlipCardsBlock(StructBlock):
template = "styleguide2/includes/organisms/cards/flip_card_list.html"
class ProgramGroupBlockPopout(SharedProgramGroupBlockPopout):
class ElectionsProgramBlock(StructBlock):
title = CharBlock(label="Titulek části programu")
program_page = PageChooserBlock(
label="Stránka",
page_type=[
"elections.ElectionsFullProgramPage",
],
required=False,
)
class Meta:
icon = "view"
label = "Program z volebního webu"
class ProgramGroupBlockPopout(SharedProgramGroupBlockPopout, ProgramGroupBlockMixin):
pass
......
# Generated by Django 4.1.13 on 2024-03-15 16:48
from django.db import migrations
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('main', '0078_alter_mainprogrampage_program'),
]
operations = [
migrations.AlterField(
model_name='mainprogrampage',
name='program',
field=wagtail.fields.StreamField([('program_group', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('point_list', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('url', wagtail.blocks.URLBlock(label='Odkaz pokrývající celou tuto část', required=False)), ('icon', wagtail.images.blocks.ImageChooserBlock(label='Ikona', required=False)), ('title', wagtail.blocks.CharBlock(label='Titulek článku programu')), ('text', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Obsah'))]), label='Jednotlivé články programu'))])), ('program_group_crossroad', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('point_list', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(label='Obrázek')), ('title', wagtail.blocks.CharBlock(label='Titulek', required=True)), ('text', wagtail.blocks.RichTextBlock(label='Krátký text pod nadpisem', required=False)), ('page', wagtail.blocks.PageChooserBlock(label='Stránka', page_type=['main.MainArticlesPage', 'main.MainArticlePage', 'main.MainProgramPage', 'main.MainPeoplePage', 'main.MainPersonPage', 'main.MainSimplePage', 'main.MainContactPage', 'main.MainCrossroadPage'], required=False)), ('link', wagtail.blocks.URLBlock(label='Odkaz', required=False))]), label='Karty programu'))])), ('program_group_popout', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek části programu')), ('categories', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('name', wagtail.blocks.CharBlock(label='Název')), ('icon', wagtail.images.blocks.ImageChooserBlock(label='Ikona', required=False)), ('point_list', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(label='Titulek vyskakovacího bloku')), ('content', wagtail.blocks.RichTextBlock(features=['h3', 'h4', 'h5', 'bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link', 'image', 'superscript', 'subscript', 'strikethrough', 'blockquote', 'embed'], label='Obsah'))]), label='Jednotlivé bloky programu'))]), label='Kategorie programu'))]))], blank=True, use_json_field=True, verbose_name='Program'),
),
]
......@@ -179,6 +179,7 @@ class MainProgramPage(
("program_group", blocks.ProgramGroupBlock()),
("program_group_crossroad", blocks.ProgramGroupBlockCrossroad()),
("program_group_popout", blocks.ProgramGroupBlockPopout()),
("elections_program", blocks.ElectionsProgramBlock()),
],
verbose_name="Program",
blank=True,
......
......@@ -48,6 +48,10 @@
{% endfor %}
</div>
</div>
{% elif program.block_type == "elections_program" %}
<div class="mb-12">
{{ program.value.program_page.get_main_page_program_render|safe }}
</div>
{% endif %}
</template>
{% endfor %}
......
......@@ -184,6 +184,8 @@ class ProgramPopoutCategory(StructBlock):
name = CharBlock(label="Název")
icon = ImageChooserBlock(label="Ikona", required=False)
description = RichTextBlock(label="Popis", required=False)
point_list = ListBlock(ProgramBlockPopout(), label="Jednotlivé bloky programu")
class Meta:
......
......@@ -6,6 +6,7 @@
bg-black text-white
{% endblock %}
"
id="aktuality"
>
<div class="container--medium __js-root">
<div
......
{% load wagtailimages_tags %}
{% load wagtailcore_tags wagtailimages_tags %}
<ul class="flex flex-col gap-6">
{% for category in categories %}
<li class="grow">
<div class="flex gap-3 mb-3 items-center bg-grey-150 p-5">
{% image category.icon max-75x75 as icon %}
{% if category.icon %}
{% image category.icon max-75x75 as icon %}
<img
src="{{ icon.url }}"
width="20"
height="20"
>
<img
src="{{ icon.url }}"
width="20"
height="20"
>
{% endif %}
<h2 class="font-alt text-2xl">{{ category.name }}</h2>
</div>
{% if category.description %}
<div class="prose max-w-screen-lg">
{{ category.description|richtext }}
</div>
{% endif %}
{% for point in category.point_list %}
{% include 'styleguide2/includes/molecules/popouts/popout_point.html' with name=point.title content=point.content %}
{% endfor %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment