Assiduites : migration heure aprem

This commit is contained in:
iziram 2023-08-22 16:18:58 +02:00
parent a04403cd0e
commit efaeeb7b5f
2 changed files with 21 additions and 4 deletions

View File

@ -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})",

View File

@ -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))