From 7289e4f1dce8d5676f5771a709a297529907a1e0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sat, 21 Nov 2020 17:45:26 +0100 Subject: [PATCH] Use ints for years --- fiches/management/commands/_ldap.py | 2 +- fiches/management/commands/add_conscrits.py | 8 ++++---- fiches/management/commands/get_photos.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fiches/management/commands/_ldap.py b/fiches/management/commands/_ldap.py index 3738376..ee88d99 100644 --- a/fiches/management/commands/_ldap.py +++ b/fiches/management/commands/_ldap.py @@ -73,7 +73,7 @@ class ClipperLDAP(LDAP): raise ValueError("Invalid home directory") # Ça casse en 2100, mais le système de naming de sas aussi... - promo = "20" + promo + promo = 2000 + int(promo) return promo, self.verbose_depts.get(dept, None) diff --git a/fiches/management/commands/add_conscrits.py b/fiches/management/commands/add_conscrits.py index 0301f21..7c81c14 100644 --- a/fiches/management/commands/add_conscrits.py +++ b/fiches/management/commands/add_conscrits.py @@ -16,7 +16,7 @@ class Command(BaseCommand): group.add_argument( "--all", action="store_true", help="Importe l'intégralité des promotions" ) - group.add_argument("--promo", help="Spécifie la promotion à importer") + group.add_argument("--promo", type=int, help="Spécifie la promotion à importer") def get_current_promo(self): today = date.today() @@ -24,15 +24,15 @@ class Command(BaseCommand): if today.month < 9: year -= 1 - return str(year) + return year def handle(self, *args, **options): if options["all"]: promo = None elif options["promo"] is not None: promo = options["promo"] - if len(promo) == 2: - promo = "20" + promo + if promo < 100: + promo = 2000 + promo else: promo = self.get_current_promo() diff --git a/fiches/management/commands/get_photos.py b/fiches/management/commands/get_photos.py index c9e1bd5..69c3a67 100644 --- a/fiches/management/commands/get_photos.py +++ b/fiches/management/commands/get_photos.py @@ -20,7 +20,7 @@ class Command(BaseCommand): group.add_argument( "--all", action="store_true", help="Importe l'intégralité des promotions" ) - group.add_argument("--promo", help="Spécifie la promotion à importer") + group.add_argument("--promo", type=int, help="Spécifie la promotion à importer") def get_current_promo(self): today = date.today() @@ -35,8 +35,8 @@ class Command(BaseCommand): promo = None elif options["promo"] is not None: promo = options["promo"] - if len(promo) == 2: - promo = "20" + promo + if promo < 100: + promo = 2000 + promo else: promo = self.get_current_promo()