Skip to content
Snippets Groups Projects

elections2021: Fix export

Merged jan.bednarik requested to merge test into master
3 files
+ 11
3
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -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)
Loading