From bd15b2f419929222d76b63ec0fae4bbf23cb8a93 Mon Sep 17 00:00:00 2001 From: Iziram Date: Mon, 13 Nov 2023 15:20:06 +0100 Subject: [PATCH] Assiduites + EDT : ajout heures liens EDT --- app/scodoc/sco_edt_cal.py | 4 +++- app/templates/assiduites/widgets/timeline.j2 | 15 +++++++++++++++ app/views/assiduites.py | 8 ++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/scodoc/sco_edt_cal.py b/app/scodoc/sco_edt_cal.py index e8ba3110..851faf6c 100644 --- a/app/scodoc/sco_edt_cal.py +++ b/app/scodoc/sco_edt_cal.py @@ -139,7 +139,9 @@ def formsemestre_edt_dict(formsemestre: FormSemestre) -> list[dict]: scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id, moduleimpl_id=modimpl.id, - jour = event.decoded("dtstart").isoformat(), + jour = event.decoded("dtstart").date().isoformat(), + heure_deb = event.decoded("dtstart").isoformat(), + heure_fin = event.decoded("dtend").isoformat(), group_ids=group.id, )}">absences """ diff --git a/app/templates/assiduites/widgets/timeline.j2 b/app/templates/assiduites/widgets/timeline.j2 index 9d614195..5cbe94f3 100644 --- a/app/templates/assiduites/widgets/timeline.j2 +++ b/app/templates/assiduites/widgets/timeline.j2 @@ -260,6 +260,21 @@ return ((a - b) / (t_end - t_start)) * 100; } function fromTime(time, separator = ":") { + // On peut recevoir 2 formats + // "HH:MM" ou "2023-11-15T16:30:00+00:00" + + // Si on a le format : "2023-11-15T16:30:00+00:00" + if (time.indexOf("T") != -1) { + // On récupère uniquement le temps + + time = new Date(time).toTimeString() + let match = time.match(/(\d\d:){2}(\d\d)/g) + if (match == null) { + throw RangeError(`Invalid Time -> ${time}`) + } + time = match[0] + } + const [hours, minutes] = time.split(separator).map((el) => Number(el)) return hours + minutes / 60 } diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 88a482ad..cc2080d9 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -263,8 +263,8 @@ def signal_assiduites_etud(): # Récupération de la date (par défaut la date du jour) date = request.args.get("date", datetime.date.today().isoformat()) heures: list[str] = [ - request.args.get("heure_deb", ""), - request.args.get("heure_fin", ""), + request.args.get("heure_deb", "").replace("%2B", "+"), + request.args.get("heure_fin", "").replace("%2B", "+"), ] # gestion évaluations (Appel à la page depuis les évaluations) @@ -581,8 +581,8 @@ def signal_assiduites_group(): moduleimpl_id: int = request.args.get("moduleimpl_id") date: str = request.args.get("jour", datetime.date.today().isoformat()) heures: list[str] = [ - request.args.get("heure_deb", ""), - request.args.get("heure_fin", ""), + request.args.get("heure_deb", "").replace("%2B", "+"), + request.args.get("heure_fin", "").replace("%2B", "+"), ] group_ids: list[int] = request.args.get("group_ids", None) if group_ids is None: