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

elections2021: Fix export

parent 2a2c8d35
No related branches found
No related tags found
2 merge requests!289elections2021: Fix export,!288elections2021: Fix export
Pipeline #3941 passed
......@@ -5,7 +5,7 @@ from django.template.loader import render_to_string
from django.utils import timezone
from weasyprint import CSS, HTML
from ...constants import MINISTRY_CHOICES, MINISTRY_CODES
from ...constants import BENEFITS_CHOICES, MINISTRY_CHOICES, MINISTRY_CODES
from ...models import Elections2021ProgramPointPage
......@@ -19,6 +19,8 @@ class Command(BaseCommand):
parser.add_argument("output", type=str, help=".pdf nebo .html soubor")
def handle(self, *args, **options):
benefits_titles = {num: title for num, title in BENEFITS_CHOICES}
toc = []
body = []
......@@ -27,7 +29,8 @@ class Command(BaseCommand):
points = []
for page in get_ministry_points(ministry):
value = render_to_string(
"elections2021/export_program_point.html", {"page": page}
"elections2021/export_program_point.html",
{"page": page, "benefits_titles": benefits_titles},
)
value = re.sub(r'href="#zdroje"', f'href="#zdroje_{page.id}"', value)
points.append(value)
......
......@@ -27,7 +27,7 @@
<h3 class="section-title">Pro koho to chceme hlavně</h3>
<div>
{% for block in page.benefits_main %}
<h4>{{ block.value.title }}</h4>
<h4>{{ benefits_titles|dictitem:block.value.variant }}</h4>
<div>{{ block.value.text|richtext|format_sources }}</div>
{% endfor %}
{% for block in page.benefits %}
......
......@@ -66,3 +66,8 @@ def strip_sup(value):
for sup in soup.find_all("sup"):
sup.decompose()
return str(soup)
@register.filter
def dictitem(dictionary, key):
return dictionary.get(key)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment