From 677415fbfcaf46c998359fd7efd2800352525dba Mon Sep 17 00:00:00 2001 From: Lyanis Souidi Date: Sat, 10 Feb 2024 14:11:34 +0100 Subject: [PATCH] Ajout des annotations dans l'API --- app/models/etudiants.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 6a275b46b..21b8d1cea 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -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