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

random other candidates

parent 412c7b58
Branches
No related tags found
2 merge requests!899Release,!886Random other candidates
Pipeline #16316 passed
# Generated by Django 4.1.10 on 2024-01-18 09:15
import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("elections", "0008_alter_electionshomepage_content"),
]
operations = [
migrations.RemoveField(
model_name="electionscandidatepage",
name="related_candidates",
),
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(
help_text="Pro zobrazení odkazu na celou verzi programu musí být obě následující pole vyplněná.",
label="Odkaz na celou verzi programu",
required=False,
),
),
(
"long_version_text",
wagtail.blocks.CharBlock(
label="Nadpis odkazu na celou verzi programu",
required=False,
),
),
]
),
),
(
"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",
),
),
]
...@@ -226,21 +226,6 @@ class ElectionsCandidatePage( ...@@ -226,21 +226,6 @@ class ElectionsCandidatePage(
help_text='Např. "Aktuality Mikuláše Peksy".', help_text='Např. "Aktuality Mikuláše Peksy".',
) )
related_candidates = StreamField(
[
(
"candidate",
PageChooserBlock(
page_type="elections.ElectionsCandidatePage",
label="Detail kandidáta",
),
)
],
verbose_name="Další kandidáti",
blank=True,
use_json_field=True,
)
## PANELS ## PANELS
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
...@@ -251,7 +236,6 @@ class ElectionsCandidatePage( ...@@ -251,7 +236,6 @@ class ElectionsCandidatePage(
FieldPanel("phone"), FieldPanel("phone"),
FieldPanel("social_links"), FieldPanel("social_links"),
FieldPanel("articles_heading"), FieldPanel("articles_heading"),
FieldPanel("related_candidates"),
] ]
promote_panels = make_promote_panels() promote_panels = make_promote_panels()
...@@ -271,6 +255,12 @@ class ElectionsCandidatePage( ...@@ -271,6 +255,12 @@ class ElectionsCandidatePage(
def get_context(self, request) -> dict: def get_context(self, request) -> dict:
context = super().get_context(request) context = super().get_context(request)
context["related_candidates_list"] = (
ElectionsCandidatePage.objects.filter(~models.Q(id=self.id))
.order_by("?")
.live()[:3]
)
context["article_data_list"] = ( context["article_data_list"] = (
ElectionsArticlePage.objects.filter(author_page=self.id) ElectionsArticlePage.objects.filter(author_page=self.id)
.order_by("-date") .order_by("-date")
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
{% include 'styleguide2/includes/organisms/articles/elections/candidate_articles_section.html' with title=page.articles_heading %} {% include 'styleguide2/includes/organisms/articles/elections/candidate_articles_section.html' with title=page.articles_heading %}
{% endif %} {% endif %}
{% if page.related_candidates %} {% if related_candidates_list %}
{% include 'styleguide2/includes/organisms/candidates/elections/candidate_footer_list.html' with candidates=page.related_candidates %} {% include 'styleguide2/includes/organisms/candidates/elections/candidate_footer_list.html' with candidates=related_candidates_list %}
{% endif %} {% endif %}
</main> </main>
{% endblock %} {% endblock %}
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
scroller-classes="!text-black" scroller-classes="!text-black"
> >
{% for candidate in candidates %} {% for candidate in candidates %}
{% include 'styleguide2/includes/molecules/candidates/elections/candidate_footer_box.html' with candidate_page=candidate.value %} {% include 'styleguide2/includes/molecules/candidates/elections/candidate_footer_box.html' with candidate_page=candidate %}
{% endfor %} {% endfor %}
</ui-horizontal-scrollable> </ui-horizontal-scrollable>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment