From dbb1264863bf118f18899914d18058acb6449e69 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 29 Jun 2022 13:56:36 +0200 Subject: [PATCH] Fix: AP formsemestre avec parcours --- app/api/formsemestres.py | 2 +- app/models/formsemestre.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 725454b1..be7bf1e0 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -54,7 +54,7 @@ def formsemestre(formsemestre_id: int): formsemestre: FormSemestre = models.FormSemestre.query.filter_by( id=formsemestre_id ).first_or_404() - data = formsemestre.to_dict() + data = formsemestre.to_dict(convert_parcours=True) # Pour le moment on a besoin de fixer le departement # pour accéder aux préferences dept = Departement.query.get(formsemestre.dept_id) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 7dc08382..8d982847 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -141,7 +141,7 @@ class FormSemestre(db.Model): def __repr__(self): return f"<{self.__class__.__name__} {self.id} {self.titre_num()}>" - def to_dict(self): + def to_dict(self, convert_parcours=False): "dict (compatible ScoDoc7)" d = dict(self.__dict__) d.pop("_sa_instance_state", None) @@ -160,6 +160,8 @@ class FormSemestre(db.Model): d["date_fin"] = d["date_fin_iso"] = "" d["responsables"] = [u.id for u in self.responsables] d["titre_formation"] = self.titre_formation() + if convert_parcours: + d["parcours"] = [p.to_dict() for p in self.parcours] return d def get_infos_dict(self) -> dict: