From 8d7b9f5e9156e9153b6060a8a7a0c33b188f21b7 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 29 Sep 2017 21:39:13 +0200 Subject: Ajout d’une option pour récupérer tout un emploi du temps Pas encore testé parce que j’aime vivre dangereusement --- management/commands/timetables.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'management') diff --git a/management/commands/timetables.py b/management/commands/timetables.py index 7ee63af..279de89 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -60,12 +60,15 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument("--week", type=int, choices=range(1, 54), nargs="+") parser.add_argument("--year", type=int, nargs=1) + parser.add_argument("--all", const=True, default=False, action="store_const") def handle(self, *args, **options): year = None errcount = 0 - if options["week"] is None: + if options["all"]: + weeks = None + elif options["week"] is None: _, week, day = timezone.now().isocalendar() if day >= 6: year, week, _ = (timezone.now() + datetime.timedelta(weeks=1)).isocalendar() @@ -73,10 +76,11 @@ class Command(BaseCommand): else: weeks = options["week"] - if options["year"] is None and year is None: - year = timezone.now().year - elif year is None: - year = options["year"][0] + if not options["all"]: + if options["year"] is None and year is None: + year = timezone.now().year + elif year is None: + year = options["year"][0] for timetable in Timetable.objects.all(): self.stdout.write("Processing {0}".format(timetable)) -- cgit v1.2.1