diff --git a/elections2021/models.py b/elections2021/models.py index ead2809f44da3258c456fb1ed2f7f1fdf2975cec..07a9faed89aaf742cdc59dcf1f8068e682a56594 100644 --- a/elections2021/models.py +++ b/elections2021/models.py @@ -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") diff --git a/elections2021/templates/elections2021/base.html b/elections2021/templates/elections2021/base.html index 6ebf6ec445a269a3a387279f652f38519fb711da..8ce3f83017b4c1a871619181d5eec952656df04f 100644 --- a/elections2021/templates/elections2021/base.html +++ b/elections2021/templates/elections2021/base.html @@ -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 %} diff --git a/elections2021/templates/elections2021/elections2021_full_program_page.html b/elections2021/templates/elections2021/elections2021_full_program_page.html new file mode 100644 index 0000000000000000000000000000000000000000..9c624eb6e24299698ecfe6668e70e9e268e22631 --- /dev/null +++ b/elections2021/templates/elections2021/elections2021_full_program_page.html @@ -0,0 +1,126 @@ +{% 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 %} diff --git a/elections2021/templatetags/elections2021_extras.py b/elections2021/templatetags/elections2021_extras.py index 762674efa9e4166b450490c28fa6a38c3995dbf9..5b13e257dac446665ae2501175d26c82ecede796 100644 --- a/elections2021/templatetags/elections2021_extras.py +++ b/elections2021/templatetags/elections2021_extras.py @@ -52,10 +52,13 @@ 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"): - sup.wrap(soup.new_tag("a", href="#zdroje")) + if arg: + sup.wrap(soup.new_tag("a", href=f"#zdroje_{arg}")) + else: + sup.wrap(soup.new_tag("a", href="#zdroje")) return str(soup)