modif export json (retours Seb)

This commit is contained in:
Emmanuel Viennet 2021-12-03 15:44:57 +01:00
parent 6627a9c6b2
commit 958539977a

View File

@ -56,6 +56,7 @@ class ApcReferentielCompetences(db.Model, XMLModel):
lazy="dynamic",
cascade="all, delete-orphan",
)
formations = db.relationship("Formation", backref="referentiel_competence")
def to_dict(self):
"""Représentation complète du ref. de comp.
@ -66,7 +67,9 @@ class ApcReferentielCompetences(db.Model, XMLModel):
"specialite": self.specialite,
"specialite_long": self.specialite_long,
"type_titre": self.type_titre,
"scodoc_date_loaded": self.scodoc_date_loaded.isoformat() + "Z",
"scodoc_date_loaded": self.scodoc_date_loaded.isoformat() + "Z"
if self.scodoc_date_loaded
else "",
"scodoc_orig_filename": self.scodoc_orig_filename,
"competences": {x.titre: x.to_dict() for x in self.competences},
"parcours": {x.code: x.to_dict() for x in self.parcours},
@ -188,7 +191,7 @@ class ApcAppCritique(db.Model, XMLModel):
)
def to_dict(self):
return {"code": self.code, "libelle": self.libelle}
return {"libelle": self.libelle}
def get_label(self):
return self.code + " - " + self.titre
@ -243,7 +246,7 @@ class ApcAnneeParcours(db.Model, XMLModel):
return {
"ordre": self.ordre,
"competences": {
x.competence.titre: {"niveau": x.niveau, "titre": x.competence.titre}
x.competence.titre: {"niveau": x.niveau}
for x in self.niveaux_competences
},
}