Skip to content
Snippets Groups Projects
Commit f32edf16 authored by jan.bednarik's avatar jan.bednarik
Browse files

elections2021: Full program page

parent 9f4cc82f
No related branches found
No related tags found
2 merge requests!396elections2021: Full program page,!395elections2021: Full program page
Pipeline #5191 passed
......@@ -58,6 +58,7 @@ from .constants import (
MINISTRY_ARCHETYPES,
MINISTRY_BUSINESS,
MINISTRY_CHOICES,
MINISTRY_CODES,
MINISTRY_COUNTRYSIDE,
MINISTRY_CULTURE,
MINISTRY_DEFENSE,
......@@ -1465,6 +1466,31 @@ class Elections2021ProgramPage(
}
return self.render(request, context_overrides=context)
@route(r"^kompletni/$")
def full_program(self, request):
benefits_titles = dict(BENEFITS_CHOICES)
toc = []
body = []
for ministry, title in MINISTRY_CHOICES:
sub_toc = []
points = []
weight = f"weight_ministry_{MINISTRY_CODES[ministry]}"
for page in Elections2021ProgramPointPage.filter_by_weights([weight]):
points.append(page)
sub_toc.append({"anchor": page.slug, "title": page.title})
body.append({"anchor": ministry, "title": title, "points": points})
toc.append({"anchor": ministry, "title": title, "sub_toc": sub_toc})
context = {"body": body, "toc": toc, "benefits_titles": benefits_titles}
return self.render(
request,
context_overrides=context,
template="elections2021/elections2021_full_program_page.html",
)
class QuestionBlock(blocks.StructBlock):
question = blocks.CharBlock(label="otázka")
......
......@@ -44,6 +44,16 @@
.navbar-menu__submenu {
line-height: 200%;
}
.content-block a:not(.contact-line):not(.content-block--nostyle) sup,
.content-block a:not(.contact-line):not(.content-block--nostyle)[id^=reference],
a sup,
a[id^=reference],
.text-fxactivecolor {
color: #6b7d09;
}
.accordeon-row--open a, .accordeon-row--open a sup {
color: #adc90e !important;
}
</style>
{% block head %}{% endblock %}
......
{% extends "elections2021/base.html" %}
{% load static wagtailcore_tags elections2021_extras %}
{% block head %}
<style type="text/css">
[role="navigation"] li {
display: block;
margin-bottom: 0.5em;
color: #515e07;
}
.content-block .unordered-list-checks li::before {
color: #000000;
content: "\e919";
font-size: .6em;
line-height: 1rem;
}
.content-block .unordered-list-checks li {
padding: 0 1rem;
margin: 0.2rem 0;
line-height: 1.5rem;
}
</style>
{% endblock %}
{% block content_header %}
<article class="relative bg-lemon md:bg-split-color px-4 md:pl-8 md:pr-0 2xl:px-8 hero py-0 w-full">
<div class="2xl:container w-auto bg-lemon md:pl-20 pr-0 grid lg:grid-rows-1 h-40 sm:h-56 md:h-64 lg:grid-cols-7 items-center 2xl:mx-auto">
<div class="lg:row-span-1 lg:col-span-4 order-1 md:pr-20">
<h1 class="head-alt-md sm:head-alt-lg pt-1">Kompletní program koalice Piráti a Starostové</h1>
</div>
</div>
</article>
{% endblock %}
{% block content %}
<div class="container container--default py-8 lg:py-16">
<div role="navigation" aria-label="Hlavní rozcestník" class="mb-16">
<h2 class="head-alt-md">obsah</h2>
<ul class="unordered-list my-8">
{% for item in toc %}
<li role="presentation">
<a href="#{{ item.anchor }}" role="menuitem" class="underline pb-2">{{ item.title }}</a><br>
<ul>
{% for sub in item.sub_toc %}
<li role="presentation"><a href="#{{ sub.anchor }}" role="menuitem" class="underline pb-2">{{ sub.title }}</a></li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
{% for item in body %}
<div id="{{ item.anchor }}" tabindex="0">
<h2 class="head-alt-lg head-alt-highlighted">Resort: {{ item.title }}</h2>
{% for point in item.points %}
<section id="{{ point.slug }}" tabindex="0" class="my-16 content-block">
<h3 class="head-alt-md head-alt-highlighted">{{ point.title }}</h3>
<div class="mt-4">{{ point.annotation|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">Takhle to dál nejde</h4>
<div>{{ point.problem|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">V čem je problém</h4>
<div>{{ point.context|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">Naše vize</h4>
<div>{{ point.ideal|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">Jak to chceme udělat?</h4>
<div>{{ point.proposal|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">Kolik na to chceme času?</h4>
<div>
{% if point.time_horizon_number %}
<p>{{ point.time_horizon_number }} {{ point.time_horizon_unit }}</p>
{% endif %}
{% if point.time_horizon_text %}
<p>{{ point.time_horizon_text|richtext|format_sources:point.id }}</p>
{% endif %}
</div>
<h4 class="head-alt-sm">Pro koho to chceme hlavně</h4>
<div>
{% for block in point.benefits_main %}
<h5>{{ benefits_titles|dictitem:block.value.variant }}</h5>
<div>{{ block.value.text|richtext|format_sources:point.id }}</div>
{% endfor %}
{% for block in point.benefits %}
<h5>{{ block.value.title }}</h5>
<div>{{ block.value.text|richtext|format_sources:point.id }}</div>
{% endfor %}
</div>
{% if point.benefit_for_all %}
<h4 class="head-alt-sm">Benefit pro všechny</h4>
<div>{{ point.benefit_for_all|richtext|format_sources:point.id }}</div>
{% endif %}
<h4 class="head-alt-sm">Co pro to už děláme</h4>
<div>{{ point.already_done|richtext|format_sources:point.id }}</div>
<h4 class="head-alt-sm">Na co se nás často ptáte</h4>
<div>
{% for block in point.faq %}
<h5>{{ block.value.question }}</h5>
<div>{{ block.value.answer|richtext|format_sources:point.id }}</div>
{% endfor %}
</div>
<h4 class="head-alt-sm" id="zdroje_{{ point.id }}">Klidně si to ověřte</h4>
<div>{{ point.sources|richtext|format_sources_block }}</div>
</section>
{% endfor %}
</div>
{% endfor %}
</div>
{% endblock %}
......@@ -52,9 +52,12 @@ def format_sources_block(value):
@register.filter(is_safe=True)
@stringfilter
def format_sources(value):
def format_sources(value, arg=None):
soup = bs4.BeautifulSoup(value, "html.parser")
for sup in soup.find_all("sup"):
if arg:
sup.wrap(soup.new_tag("a", href=f"#zdroje_{arg}"))
else:
sup.wrap(soup.new_tag("a", href="#zdroje"))
return str(soup)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment