Skip to content
Snippets Groups Projects
Commit 49d4ebf3 authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

add program & news section

parent 43588f50
Branches
No related tags found
2 merge requests!876Fix shared articles & release elections web,!863Add elections web
...@@ -3,7 +3,10 @@ from wagtail.images.blocks import ImageChooserBlock ...@@ -3,7 +3,10 @@ from wagtail.images.blocks import ImageChooserBlock
from wagtail.blocks import ( from wagtail.blocks import (
RichTextBlock, RichTextBlock,
TextBlock, TextBlock,
CharBlock,
IntegerBlock,
PageChooserBlock, PageChooserBlock,
URLBlock,
ListBlock ListBlock
) )
...@@ -53,3 +56,47 @@ class CandidateListBlock(StructBlock): ...@@ -53,3 +56,47 @@ class CandidateListBlock(StructBlock):
template = "styleguide2/includes/organisms/candidates/elections/candidate_primary_list.html" template = "styleguide2/includes/organisms/candidates/elections/candidate_primary_list.html"
icon = "form" icon = "form"
label = "Seznam kandidátů" label = "Seznam kandidátů"
class ProgramCategoryItemBlock(StructBlock):
number = IntegerBlock(label="Číslo")
content = TextBlock(label="Obsah")
class Meta:
icon = "form"
label = "Bod"
class ProgramCategoryBlock(StructBlock):
number = IntegerBlock(
label="Číslo"
)
name = CharBlock(
label="Název"
)
points = ListBlock(
ProgramCategoryItemBlock(),
label="Body"
)
class Meta:
icon = "form"
label = "Kategorie"
class ProgramBlock(StructBlock):
categories = ListBlock(
ProgramCategoryBlock(),
label="Kategorie"
)
long_version_url = URLBlock(label="Odkaz na celou verzi programu")
long_version_text = CharBlock(label="Nadpis odkazu na celou verzi programu")
class Meta:
icon = "form"
label = "Vyskakovací program"
template = "styleguide2/includes/molecules/program/card_program.html"
# Generated by Django 4.1.10 on 2024-01-05 19:47
from django.db import migrations
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('elections', '0011_alter_electionshomepage_content'),
]
operations = [
migrations.AlterField(
model_name='electionshomepage',
name='content',
field=wagtail.fields.StreamField([('carousel', wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(label='Obrázek na pozadí'))])), ('candidate', wagtail.blocks.StructBlock([('candidates', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('page', wagtail.blocks.PageChooserBlock(label='Stránka', page_type=['elections.ElectionsCandidatePage'])), ('image', wagtail.images.blocks.ImageChooserBlock(help_text='Pokud není vybrán, použije se obrázek ze stránky kandidáta', label='Obrázek', required=False)), ('description', wagtail.blocks.TextBlock(help_text='Pokud zůstane prázdné, použije se popis ze stránky kandidáta', label='Popis', required=False))]), label='Kandidáti'))])), ('program', wagtail.blocks.StructBlock([('categories', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('number', wagtail.blocks.IntegerBlock(label='Číslo')), ('name', wagtail.blocks.CharBlock(label='Název')), ('points', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('number', wagtail.blocks.IntegerBlock(label='Číslo')), ('content', wagtail.blocks.RichTextBlock(label='Obsah'))]), label='Body'))]), label='Kategorie')), ('long_version_url', wagtail.blocks.URLBlock(label='Odkaz na celou verzi programu')), ('long_version_text', wagtail.blocks.CharBlock(label='Nadpis odkazu na celou verzi programu'))]))], blank=True, use_json_field=True, verbose_name='Hlavní obsah'),
),
]
...@@ -55,7 +55,9 @@ class ElectionsHomePage(MainHomePageMixin): ...@@ -55,7 +55,9 @@ class ElectionsHomePage(MainHomePageMixin):
content = StreamField( content = StreamField(
[ [
("carousel", blocks.ElectionsCarouselBlock()), ("carousel", blocks.ElectionsCarouselBlock()),
("candidate", blocks.CandidateListBlock()) ("candidate", blocks.CandidateListBlock()),
("program", blocks.ProgramBlock()),
("news", shared_blocks.NewsBlock(template="styleguide2/includes/organisms/articles/elections/articles_section.html")),
], ],
verbose_name="Hlavní obsah", verbose_name="Hlavní obsah",
blank=True, blank=True,
......
from django import template
register = template.Library()
@register.filter
def rawtext(source_text_block) -> str:
return str(source_text_block)
...@@ -103,19 +103,6 @@ class HomePageCarouseSlideBlock(StructBlock): ...@@ -103,19 +103,6 @@ class HomePageCarouseSlideBlock(StructBlock):
label = "Carousel" label = "Carousel"
class NewsBlock(StructBlock):
title = CharBlock(
label="Titulek",
help_text="Nejnovější články se načtou automaticky",
)
description = TextBlock(label="Popis")
class Meta:
template = "styleguide2/includes/organisms/articles/articles_section.html"
icon = "doc-full-inverse"
label = "Novinky"
class EuroparlNewsBlock(StructBlock): class EuroparlNewsBlock(StructBlock):
class Meta: class Meta:
template = ( template = (
......
...@@ -55,7 +55,7 @@ class MainHomePage(MainHomePageMixin): ...@@ -55,7 +55,7 @@ class MainHomePage(MainHomePageMixin):
content = StreamField( content = StreamField(
[ [
("carousel", blocks.HomePageCarouseSlideBlock()), ("carousel", blocks.HomePageCarouseSlideBlock()),
("news", blocks.NewsBlock()), ("news", shared_blocks.NewsBlock(template="styleguide2/includes/organisms/articles/articles_section.html")),
("europarl_news", blocks.EuroparlNewsBlock()), ("europarl_news", blocks.EuroparlNewsBlock()),
("people", blocks.PeopleOverviewBlock()), ("people", blocks.PeopleOverviewBlock()),
("regions", blocks.RegionsBlock()), ("regions", blocks.RegionsBlock()),
......
...@@ -5,6 +5,7 @@ from wagtail.blocks import ( ...@@ -5,6 +5,7 @@ from wagtail.blocks import (
PageChooserBlock, PageChooserBlock,
RichTextBlock, RichTextBlock,
StructBlock, StructBlock,
TextBlock,
URLBlock, URLBlock,
) )
from wagtail.documents.blocks import DocumentChooserBlock from wagtail.documents.blocks import DocumentChooserBlock
...@@ -68,6 +69,18 @@ class SocialLinkBlock(LinkBlock): ...@@ -68,6 +69,18 @@ class SocialLinkBlock(LinkBlock):
# Articles # Articles
class NewsBlock(StructBlock):
title = CharBlock(
label="Titulek",
help_text="Nejnovější články se načtou automaticky",
)
description = TextBlock(label="Popis")
class Meta:
icon = "doc-full-inverse"
label = "Novinky"
class ArticleQuoteBlock(StructBlock): class ArticleQuoteBlock(StructBlock):
quote = CharBlock(label="Citace") quote = CharBlock(label="Citace")
autor_name = CharBlock(label="Jméno autora") autor_name = CharBlock(label="Jméno autora")
......
{% load rawtext %}
<div class="bg-pirati-yellow">
<div
class="__js-root container--wide"
id="program"
>
<ui-card-program
:points="
[
{% for category in self.categories %}
{
slug: '{{ category.number }}',
number: {{ category.number }},
title: '{{ category.name }}',
points: [
{% for point in category.points %}
{
number: '{{ point.number }}',
content: '{{ point.content|rawtext }}'
}{% if not forloop.last %},{% endif %}
{% endfor %}
]
}{% if not forloop.last %},{% endif %}
{% endfor %}
]
"
></ui-card-program>
<!-- Make this accessible without JS, at least -->
<a
class="text-xl font-bold pl-4"
href="{{ self.long_version_url }}"
>
<i class="ico--chevron-right"></i>
{{ self.long_version_text }}
</a>
</div>
</div>
{% load wagtailcore_tags wagtailimages_tags shared_perex %} {% load wagtailcore_tags wagtailimages_tags shared_perex %}
<div class="bg-black text-white"> <div
class="
{% block wrapper_classes %}
bg-black text-white
{% endblock %}
"
>
<div class="container--medium __js-root"> <div class="container--medium __js-root">
<div <div
class=" class="
...@@ -33,9 +39,11 @@ ...@@ -33,9 +39,11 @@
<div <div
class=" class="
flex justify-center pb-0 pt-12 {% block button_wrapper_classes %}
flex justify-center pt-12
xl:py-24 xl:py-24
{% endblock %}
" "
> >
{% include "styleguide2/includes/atoms/buttons/round_button.html" with button_text="Více článků" classes="bg-white text-black" url=page.root_page.articles_page.url %} {% include "styleguide2/includes/atoms/buttons/round_button.html" with button_text="Více článků" classes="bg-white text-black" url=page.root_page.articles_page.url %}
......
{% load wagtailimages_tags %} {% load wagtailimages_tags wagtailcore_tags %}
<ul <ul
class="candidate-primary-list __js-root" class="candidate-primary-list __js-root"
id="{{ id }}" id="kandidati"
> >
{% for candidate in self.candidates %} {% for candidate in self.candidates %}
{% firstof candidate.description candidate.page.description as description %} {% firstof candidate.description candidate.page.perex as description %}
{% if candidate.image %} {% if candidate.image %}
{% image candidate.image original as resized_candidate_image %} {% image candidate.image original as resized_candidate_image %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment