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

elections2021: Exports by ministry

parent 07175eda
No related branches found
No related tags found
2 merge requests!326elections2021: Exports by ministry,!325elections2021: Exports by ministry
Pipeline #4609 passed
...@@ -86,15 +86,18 @@ def plain_export(output_file, output_format): ...@@ -86,15 +86,18 @@ def plain_export(output_file, output_format):
file.write(content) file.write(content)
def fancy_export(output_file): def fancy_export(output_file, ministry=None):
tmp_file = f"{output_file}.tmp" tmp_file = f"{output_file}.tmp"
benefits_titles = dict(BENEFITS_CHOICES) benefits_titles = dict(BENEFITS_CHOICES)
pages = ( if ministry is None:
Elections2021ProgramPointPage.objects.live() pages = (
.specific() Elections2021ProgramPointPage.objects.live()
.order_by("-default_order") .specific()
) .order_by("-default_order")
)
else:
pages = get_ministry_points(ministry)
points = [] points = []
for page in pages: for page in pages:
...@@ -133,6 +136,7 @@ class Command(BaseCommand): ...@@ -133,6 +136,7 @@ class Command(BaseCommand):
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument("output", type=str, help=".pdf nebo .html soubor") parser.add_argument("output", type=str, help=".pdf nebo .html soubor")
parser.add_argument("--fancy", action="store_true") parser.add_argument("--fancy", action="store_true")
parser.add_argument("--ministry", type=str)
def handle(self, *args, **options): def handle(self, *args, **options):
output_file = options["output"] output_file = options["output"]
...@@ -147,6 +151,6 @@ class Command(BaseCommand): ...@@ -147,6 +151,6 @@ class Command(BaseCommand):
if options["fancy"]: if options["fancy"]:
if output_format != FORMAT_PDF: if output_format != FORMAT_PDF:
raise CommandError("Fancy export lze udělat jen do .pdf") raise CommandError("Fancy export lze udělat jen do .pdf")
fancy_export(output_file) fancy_export(output_file, options["ministry"])
else: else:
plain_export(output_file, output_format) plain_export(output_file, output_format)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment