From efaeeb7b5fcaa408882776bd5ac3e5dab24f7d02 Mon Sep 17 00:00:00 2001 From: iziram Date: Tue, 22 Aug 2023 16:18:58 +0200 Subject: [PATCH] Assiduites : migration heure aprem --- scodoc.py | 15 ++++++++++++--- tools/migrate_abs_to_assiduites.py | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scodoc.py b/scodoc.py index aef11ae0ab..f7e7266f79 100755 --- a/scodoc.py +++ b/scodoc.py @@ -660,7 +660,12 @@ def profile(host, port, length, profile_dir): @click.option( "-n", "--noon", - help="Spécifie l'heure de fin du matin (et donc début de l'après-midi) format `hh:mm`", + help="Spécifie l'heure de fin du matin format `hh:mm`", +) +@click.option( + "-a", + "--afternoon", + help="Spécifie l'heure de début de l'après-midi format `hh:mm` valeur identique à --noon si non spécifié", ) @click.option( "-e", @@ -669,10 +674,14 @@ def profile(host, port, length, profile_dir): ) @with_appcontext def migrate_abs_to_assiduites( - dept: str = None, morning: str = None, noon: str = None, evening: str = None + dept: str = None, + morning: str = None, + noon: str = None, + afternoon: str = None, + evening: str = None, ): # migrate-abs-to-assiduites """Permet de migrer les absences vers le nouveau module d'assiduités""" - tools.migrate_abs_to_assiduites(dept, morning, noon, evening) + tools.migrate_abs_to_assiduites(dept, morning, noon, afternoon, evening) # import cProfile # cProfile.runctx( # f"tools.migrate_abs_to_assiduites({dept})", diff --git a/tools/migrate_abs_to_assiduites.py b/tools/migrate_abs_to_assiduites.py index 0234a518c7..68e2cab98e 100644 --- a/tools/migrate_abs_to_assiduites.py +++ b/tools/migrate_abs_to_assiduites.py @@ -47,6 +47,7 @@ class _glob: MORNING: time = None NOON: time = None + AFTERNOON: time = None EVENING: time = None @@ -93,7 +94,7 @@ class _Merger: time_ = _glob.NOON if end else _glob.MORNING date_ = datetime.combine(couple[0], time_) else: - time_ = _glob.EVENING if end else _glob.NOON + time_ = _glob.EVENING if end else _glob.AFTERNOON date_ = datetime.combine(couple[0], time_) d = localize_datetime(date_) return d @@ -229,6 +230,7 @@ def migrate_abs_to_assiduites( dept: str = None, morning: str = None, noon: str = None, + afternoon: str = None, evening: str = None, debug: bool = False, ): @@ -266,6 +268,12 @@ def migrate_abs_to_assiduites( noon: list[str] = str(noon).split(":") _glob.NOON = time(int(noon[0]), int(noon[1])) + if afternoon is None: + afternoon = ScoDocSiteConfig.get("assi_lunch_time", time(13, 0)) + + afternoon: list[str] = str(afternoon).split(":") + _glob.AFTERNOON = time(int(afternoon[0]), int(afternoon[1])) + if evening is None: evening = ScoDocSiteConfig.get("assi_afternoon_time", time(18, 0))