From 9bd2290076295ce6f2fe2973970b26c65d3a4fbb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 22 Jul 2022 21:22:06 +0200 Subject: [PATCH] API: fix /formsemestre//etat_evals et /formsemestre/ --- app/api/formsemestres.py | 8 +++----- app/models/formsemestre.py | 7 ++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index a27a68f8..2f25b28c 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -342,10 +342,8 @@ def etat_evals(formsemestre_id: int): date_debut = notes_sorted[0].date date_fin = notes_sorted[-1].date - # Récupération de l'id de la note médiane - list_id_notes_sorted = [note.id for note in notes_sorted] - id_mediane = list_id_notes_sorted[len(list_id_notes_sorted) // 2] - date_mediane = notes_sorted[id_mediane].date + # Note médiane + date_mediane = notes_sorted[len(notes_sorted) // 2].date eval_dict["saisie_notes"] = { "datetime_debut": date_debut.isoformat() @@ -357,7 +355,7 @@ def etat_evals(formsemestre_id: int): else None, } - list_eval.append(eval) + list_eval.append(eval_dict) modimpl_dict["evaluations"] = list_eval result.append(modimpl_dict) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 9ff939d4..b3688dd9 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -179,8 +179,6 @@ class FormSemestre(db.Model): d = dict(self.__dict__) d.pop("_sa_instance_state", None) d["annee_scolaire"] = self.annee_scolaire_str() - d["formsemestre_id"] = self.id - d["titre_num"] = self.titre_num() if self.date_debut: d["date_debut"] = self.date_debut.strftime("%d/%m/%Y") d["date_debut_iso"] = self.date_debut.isoformat() @@ -191,9 +189,12 @@ class FormSemestre(db.Model): d["date_fin_iso"] = self.date_fin.isoformat() else: d["date_fin"] = d["date_fin_iso"] = "" + d["etape_apo"] = self.etapes_apo_str() + d["formsemestre_id"] = self.id + d["parcours"] = [p.to_dict() for p in self.parcours] d["responsables"] = [u.id for u in self.responsables] d["titre_court"] = self.formation.acronyme - d["parcours"] = [p.to_dict() for p in self.parcours] + d["titre_num"] = self.titre_num() d["session_id"] = self.session_id() return d