From 5e46d2fc3581653401d562b16b54c178add14688 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 19 May 2022 04:15:26 +0200 Subject: [PATCH] Fix: json evaluations sans dates --- app/models/evaluations.py | 19 +++++++++++++------ sco_version.py | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/models/evaluations.py b/app/models/evaluations.py index ef2a62887..5b0960ba0 100644 --- a/app/models/evaluations.py +++ b/app/models/evaluations.py @@ -46,16 +46,23 @@ class Evaluation(db.Model): def __repr__(self): return f"""""" - def to_dict(self): + def to_dict(self) -> dict: + "Représentation dict, pour json" e = dict(self.__dict__) e.pop("_sa_instance_state", None) # ScoDoc7 output_formators e["evaluation_id"] = self.id - e["jour"] = ndb.DateISOtoDMY(e["jour"]) - e["date_debut"] = datetime.datetime.combine( - self.jour, self.heure_debut - ).isoformat() - e["date_fin"] = datetime.datetime.combine(self.jour, self.heure_fin).isoformat() + e["jour"] = e["jour"].strftime("%d/%m/%Y") if e["jour"] else "" + if self.jour is None: + e["date_debut"] = None + e["date_fin"] = None + else: + e["date_debut"] = datetime.datetime.combine( + self.jour, self.heure_debut or datetime.time(0, 0) + ).isoformat() + e["date_fin"] = datetime.datetime.combine( + self.jour, self.heure_fin or datetime.time(0, 0) + ).isoformat() e["numero"] = ndb.int_null_is_zero(e["numero"]) e["poids"] = self.get_ue_poids_dict() # { ue_id : poids } return evaluation_enrich_dict(e) diff --git a/sco_version.py b/sco_version.py index 120447d32..3222274fa 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.21" +SCOVERSION = "9.2.22" SCONAME = "ScoDoc"