Ajout des annotations dans l'API

This commit is contained in:
Lyanis Souidi 2024-02-10 14:11:34 +01:00
parent 6cbeeedb1c
commit 677415fbfc
1 changed files with 12 additions and 0 deletions

View File

@ -518,6 +518,12 @@ class Identite(models.ScoDocModel):
e["dept_acronym"] = self.departement.acronym
e.pop("departement", None)
e["sort_key"] = self.sort_key
e["annotations"] = [
annot.to_dict()
for annot in EtudAnnotation.query.filter_by(etudid=self.id).order_by(
desc(EtudAnnotation.date)
)
]
if restrict:
# Met à None les attributs protégés:
for attr in self.protected_attrs:
@ -1076,6 +1082,12 @@ class EtudAnnotation(db.Model):
author = db.Column(db.Text) # le pseudo (user_name), was zope_authenticated_user
comment = db.Column(db.Text)
def to_dict(self):
"""Représentation dictionnaire."""
e = dict(self.__dict__)
e.pop("_sa_instance_state", None)
return e
from app.models.formsemestre import FormSemestre
from app.models.modules import Module