From 4f07bd677c8eedad03bd10196132cffc21768eb4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 27 Sep 2023 23:02:32 +0200 Subject: [PATCH] API: assiduite : ajout user_name et corrige user_id. Fixes #753 --- app/models/assiduites.py | 12 ++++-------- app/scodoc/sco_formsemestre_status.py | 2 +- sco_version.py | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/models/assiduites.py b/app/models/assiduites.py index 82b6d3dc3..0435281a3 100644 --- a/app/models/assiduites.py +++ b/app/models/assiduites.py @@ -70,16 +70,11 @@ class Assiduite(db.Model): def to_dict(self, format_api=True) -> dict: """Retourne la représentation json de l'assiduité""" etat = self.etat - username = self.user_id + user: User = None if format_api: etat = EtatAssiduite.inverse().get(self.etat).name if self.user_id is not None: - user: User = db.session.get(User, self.user_id) - - if user is None: - username = "Non renseigné" - else: - username = user.get_prenomnom() + user = db.session.get(User, self.user_id) data = { "assiduite_id": self.id, "etudid": self.etudid, @@ -90,7 +85,8 @@ class Assiduite(db.Model): "etat": etat, "desc": self.description, "entry_date": self.entry_date, - "user_id": username, + "user_id": None if user is None else user.id, # l'uid + "user_name": None if user is None else user.user_name, # le login "est_just": self.est_just, "external_data": self.external_data, } diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 9cf40e437..520af7e8f 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -884,7 +884,7 @@ def _make_listes_sem(formsemestre: FormSemestre) -> str: jour = datetime.date.today().isoformat(), group_ids=group.id, )}"> - +