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

add secondary candidate listing

parent 29f4bf4f
No related branches found
No related tags found
2 merge requests!882Release,!880Add secondary candidate listing
...@@ -53,6 +53,39 @@ class CandidateListBlock(StructBlock): ...@@ -53,6 +53,39 @@ class CandidateListBlock(StructBlock):
label = "Seznam kandidátů" label = "Seznam kandidátů"
class SecondaryCandidateBlock(StructBlock):
number = CharBlock(label="Číslo")
page = PageChooserBlock(
label="Stránka", page_type=["elections.ElectionsCandidatePage"]
)
image = ImageChooserBlock(
label="Obrázek",
help_text="Pokud není vybrán, použije se obrázek ze stránky kandidáta",
required=False,
)
class Meta:
template = "styleguide2/includes/molecules/candidates/elections/candidate_primary_box.html"
icon = "form"
label = "Kandidát"
class CandidateSecondaryListBlock(StructBlock):
heading = CharBlock(label="Nadpis")
candidates = ListBlock(
SecondaryCandidateBlock(),
label="Kandidáti",
)
class Meta:
template = "styleguide2/includes/organisms/candidates/elections/candidate_secondary_list.html"
icon = "form"
label = "Sekundární seznam kandidátů"
class ProgramCategoryItemBlock(StructBlock): class ProgramCategoryItemBlock(StructBlock):
number = IntegerBlock(label="Číslo") number = IntegerBlock(label="Číslo")
......
# Generated by Django 4.1.10 on 2024-01-17 11:38
from django.db import migrations
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
("elections", "0006_remove_electionscandidatepage_calendar_and_more"),
]
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í"
),
)
]
),
),
(
"candidates",
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(
label="Popis"
),
),
]
),
label="Kandidáti",
),
)
]
),
),
(
"secondary_candidates",
wagtail.blocks.StructBlock(
[
("heading", wagtail.blocks.CharBlock(label="Nadpis")),
(
"candidates",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"number",
wagtail.blocks.CharBlock(
label="Číslo"
),
),
(
"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,
),
),
]
),
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.TextBlock(
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"
),
),
]
),
),
(
"news",
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"),
),
],
template="styleguide2/includes/organisms/articles/elections/articles_section.html",
),
),
],
blank=True,
use_json_field=True,
verbose_name="Hlavní obsah",
),
),
]
...@@ -56,7 +56,8 @@ class ElectionsHomePage(MainHomePageMixin): ...@@ -56,7 +56,8 @@ class ElectionsHomePage(MainHomePageMixin):
content = StreamField( content = StreamField(
[ [
("carousel", blocks.ElectionsCarouselBlock()), ("carousel", blocks.ElectionsCarouselBlock()),
("candidate", blocks.CandidateListBlock()), ("candidates", blocks.CandidateListBlock()),
("secondary_candidates", blocks.CandidateSecondaryListBlock()),
("program", blocks.ProgramBlock()), ("program", blocks.ProgramBlock()),
( (
"news", "news",
......
{% load wagtailimages_tags %}
<li class="candidate-secondary-box"> <li class="candidate-secondary-box">
<a <a
href="#" href="{{ candidate.page.url }}"
class=" class="
container--wide py-2 flex gap-6 items-center underline-offset-2 container--wide py-2 flex gap-6 items-center underline-offset-2
" "
> >
<div class="font-bold text-xl"> <div class="font-bold text-xl">
{{ number }} {{ candidate.number }}
</div> </div>
<div <div
...@@ -14,18 +16,24 @@ ...@@ -14,18 +16,24 @@
flex font-bold justify-center items-center rounded-full flex font-bold justify-center items-center rounded-full
" "
> >
{% if candidate.image %}
{% image candidate.image original as resized_candidate_image %}
{% else %}
{% image candidate.page.image original as resized_candidate_image %}
{% endif %}
<img <img
class="rounded-full w-12 h-12 object-cover" class="w-12 object-cover"
src="{{ image_source }}" src="{{ resized_candidate_image.url }}"
> >
</div> </div>
<div class="flex flex-col lg:flex-row"> <div class="flex flex-col lg:flex-row">
<h4 class="text-xl font-bold">{{ name }}</h4> <h4 class="text-xl font-bold">{{ candidate.page.title }}</h4>
{% if position %} {% if candidate.page.position %}
<p><span class="hidden lg:inline">,</span> <p><span class="hidden lg:inline">,</span>
{{ position }} {{ candidate.page.position }}
</p> </p>
{% endif %} {% endif %}
</div> </div>
......
<ul class="candidate-secondary-list pt-14 pb-16"> <ul class="candidate-secondary-list pt-14 pb-16">
<div class="container--wide"> <div class="container--wide">
<h2 class="head-7xl mb-3">Další kandidáti</h2> <h2 class="head-7xl mb-3">{{ self.heading }}</h2>
</div> </div>
{% for candidate in self.candidates %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %} {% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %} {% endfor %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %}
{% include "styleguide2/includes/molecules/candidates/elections/candidate_secondary_box.html" %}
</ul> </ul>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment