diff --git a/elections2021/management/commands/export_program.py b/elections2021/management/commands/export_program.py index 0f1065d2acee353199e38a6ad295f7c3fc20843a..4fc22ba660c94bccb5f4726a7e8082e58a627f30 100644 --- a/elections2021/management/commands/export_program.py +++ b/elections2021/management/commands/export_program.py @@ -86,15 +86,18 @@ def plain_export(output_file, output_format): file.write(content) -def fancy_export(output_file): +def fancy_export(output_file, ministry=None): tmp_file = f"{output_file}.tmp" benefits_titles = dict(BENEFITS_CHOICES) - pages = ( - Elections2021ProgramPointPage.objects.live() - .specific() - .order_by("-default_order") - ) + if ministry is None: + pages = ( + Elections2021ProgramPointPage.objects.live() + .specific() + .order_by("-default_order") + ) + else: + pages = get_ministry_points(ministry) points = [] for page in pages: @@ -133,6 +136,7 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument("output", type=str, help=".pdf nebo .html soubor") parser.add_argument("--fancy", action="store_true") + parser.add_argument("--ministry", type=str) def handle(self, *args, **options): output_file = options["output"] @@ -147,6 +151,6 @@ class Command(BaseCommand): if options["fancy"]: if output_format != FORMAT_PDF: raise CommandError("Fancy export lze udělat jen do .pdf") - fancy_export(output_file) + fancy_export(output_file, options["ministry"]) else: plain_export(output_file, output_format)