1
0
forked from ScoDoc/ScoDoc

Fix: AP formsemestre avec parcours

This commit is contained in:
Emmanuel Viennet 2022-06-29 13:56:36 +02:00
parent 081ad0d5e9
commit dbb1264863
2 changed files with 4 additions and 2 deletions

View File

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

View File

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