Use ints for years
This commit is contained in:
parent
975c37afe4
commit
7289e4f1dc
3 changed files with 8 additions and 8 deletions
|
@ -73,7 +73,7 @@ class ClipperLDAP(LDAP):
|
||||||
raise ValueError("Invalid home directory")
|
raise ValueError("Invalid home directory")
|
||||||
|
|
||||||
# Ça casse en 2100, mais le système de naming de sas aussi...
|
# Ç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)
|
return promo, self.verbose_depts.get(dept, None)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Command(BaseCommand):
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--all", action="store_true", help="Importe l'intégralité des promotions"
|
"--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):
|
def get_current_promo(self):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
|
@ -24,15 +24,15 @@ class Command(BaseCommand):
|
||||||
if today.month < 9:
|
if today.month < 9:
|
||||||
year -= 1
|
year -= 1
|
||||||
|
|
||||||
return str(year)
|
return year
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
if options["all"]:
|
if options["all"]:
|
||||||
promo = None
|
promo = None
|
||||||
elif options["promo"] is not None:
|
elif options["promo"] is not None:
|
||||||
promo = options["promo"]
|
promo = options["promo"]
|
||||||
if len(promo) == 2:
|
if promo < 100:
|
||||||
promo = "20" + promo
|
promo = 2000 + promo
|
||||||
else:
|
else:
|
||||||
promo = self.get_current_promo()
|
promo = self.get_current_promo()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Command(BaseCommand):
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--all", action="store_true", help="Importe l'intégralité des promotions"
|
"--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):
|
def get_current_promo(self):
|
||||||
today = date.today()
|
today = date.today()
|
||||||
|
@ -35,8 +35,8 @@ class Command(BaseCommand):
|
||||||
promo = None
|
promo = None
|
||||||
elif options["promo"] is not None:
|
elif options["promo"] is not None:
|
||||||
promo = options["promo"]
|
promo = options["promo"]
|
||||||
if len(promo) == 2:
|
if promo < 100:
|
||||||
promo = "20" + promo
|
promo = 2000 + promo
|
||||||
else:
|
else:
|
||||||
promo = self.get_current_promo()
|
promo = self.get_current_promo()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue