aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-29 21:39:13 +0200
committerAlban Gruin2017-09-29 21:39:13 +0200
commit8d7b9f5e9156e9153b6060a8a7a0c33b188f21b7 (patch)
tree35a0248985eca1351234dfc1d53ed59386558bb5
parenta8d35aee63f073674993b8afde78a8d5c1517e05 (diff)
Ajout d’une option pour récupérer tout un emploi du temps
Pas encore testé parce que j’aime vivre dangereusement
-rw-r--r--management/commands/timetables.py14
1 files changed, 9 insertions, 5 deletions
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))