From b7f4c941c10700d4e6ae2d1ca550ce0637ed1388 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Wed, 17 Mar 2021 08:46:40 +0100 Subject: [PATCH] Add command for generating cite command for given publications --- sok/management/commands/cite.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sok/management/commands/cite.py diff --git a/sok/management/commands/cite.py b/sok/management/commands/cite.py new file mode 100644 index 0000000..a7fd190 --- /dev/null +++ b/sok/management/commands/cite.py @@ -0,0 +1,17 @@ +from typing import List + +from django.core.management.base import BaseCommand, CommandParser + +from sok.models import Publication + + +class Command(BaseCommand): + + def add_arguments(self, parser: CommandParser): + parser.add_argument('pk', nargs='+', type=int) + + def handle(self, *args, **options): + pks: List[int] = options['pk'] + publications = [Publication.objects.get(pk=pk) for pk in pks] + cite_keys = [publication.cite_key for publication in publications] + self.stdout.write(r"\cite{" + ",".join(cite_keys) + "}", ending='')