From 545c04968f5fbc7925a97625c1e6ae3fb0dfefcc Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 21 Apr 2022 16:35:27 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20traitement=20des=20d=C3=A9faillants=20(b?= =?UTF-8?q?ug=20empechant=20acc=C3=A8s=20aux=20bulletins=20ant=C3=A9rieurs?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/etudiants.py | 42 +++++++++++++++++++++------ app/scodoc/sco_formsemestre.py | 3 ++ app/scodoc/sco_formsemestre_status.py | 5 +++- app/templates/sco_value_error.html | 1 - app/views/notes.py | 5 ++-- sco_version.py | 2 +- 6 files changed, 43 insertions(+), 15 deletions(-) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 3aacb66a..b1fec609 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -302,22 +302,46 @@ class Identite(db.Model): else: date_ins = events[0].event_date situation += date_ins.strftime(" le %d/%m/%Y") + elif inscr.etat == scu.DEF: + situation = f"défaillant en {inscr.formsemestre.titre_mois()}" + event = ( + models.ScolarEvent.query.filter_by( + etudid=self.id, + formsemestre_id=inscr.formsemestre.id, + event_type="DEFAILLANCE", + ) + .order_by(models.ScolarEvent.event_date) + .first() + ) + if not event: + log( + f"*** situation inconsistante pour {self} (def mais pas d'event)" + ) + situation += "???" # ??? + else: + date_def = event.event_date + situation += date_def.strftime(" le %d/%m/%Y") + else: situation = f"démission de {inscr.formsemestre.titre_mois()}" # Cherche la date de demission dans scolar_events: - events = models.ScolarEvent.query.filter_by( - etudid=self.id, - formsemestre_id=inscr.formsemestre.id, - event_type="DEMISSION", - ).all() - if not events: + event = ( + models.ScolarEvent.query.filter_by( + etudid=self.id, + formsemestre_id=inscr.formsemestre.id, + event_type="DEMISSION", + ) + .order_by(models.ScolarEvent.event_date) + .first() + ) + if not event: log( f"*** situation inconsistante pour {self} (demission mais pas d'event)" ) - date_dem = "???" # ??? + situation += "???" # ??? else: - date_dem = events[0].event_date - situation += date_dem.strftime(" le %d/%m/%Y") + date_dem = event.event_date + situation += date_dem.strftime(" le %d/%m/%Y") else: situation = "non inscrit" + self.e diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 98fc64a2..11792057 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -95,9 +95,12 @@ _formsemestreEditor = ndb.EditableTable( def get_formsemestre(formsemestre_id, raise_soft_exc=False): "list ONE formsemestre" + if formsemestre_id is None: + raise ValueError(f"get_formsemestre: id manquant") if formsemestre_id in g.stored_get_formsemestre: return g.stored_get_formsemestre[formsemestre_id] if not isinstance(formsemestre_id, int): + log(f"get_formsemestre: invalid id '{formsemestre_id}'") raise ScoInvalidIdType("formsemestre_id must be an integer !") sems = do_formsemestre_list(args={"formsemestre_id": formsemestre_id}) if not sems: diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 98c67431..299318ed 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -966,6 +966,7 @@ Il y a des notes en attente ! Le classement des étudiants n'a qu'une valeur ind def formsemestre_status(formsemestre_id=None): """Tableau de bord semestre HTML""" # porté du DTML + sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True) modimpls = sco_moduleimpl.moduleimpl_withmodule_list( formsemestre_id=formsemestre_id @@ -987,7 +988,9 @@ def formsemestre_status(formsemestre_id=None): use_ue_coefs = sco_preferences.get_preference("use_ue_coefs", formsemestre_id) H = [ - html_sco_header.sco_header(page_title="Semestre %s" % sem["titreannee"]), + html_sco_header.sco_header( + page_title=f"{formsemestre.sem_modalite()} {formsemestre.titre_annee()}" + ), '
', formsemestre_status_head( formsemestre_id=formsemestre_id, page_title="Tableau de bord" diff --git a/app/templates/sco_value_error.html b/app/templates/sco_value_error.html index 8a54f619..524f4d88 100644 --- a/app/templates/sco_value_error.html +++ b/app/templates/sco_value_error.html @@ -1,6 +1,5 @@ {# -*- mode: jinja-html -*- #} {% extends 'base.html' %} -{% import 'bootstrap/wtf.html' as wtf %} {% block app_content %} diff --git a/app/views/notes.py b/app/views/notes.py index 061055f8..d6c6e1b0 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -290,10 +290,9 @@ def formsemestre_bulletinetud( code_ine=None, ): format = format or "html" - if not formsemestre_id: - flask.abort(404, "argument manquant: formsemestre_id") + if not isinstance(formsemestre_id, int): - raise ScoInvalidIdType("formsemestre_id must be an integer !") + raise ValueError("formsemestre_id must be an integer !") formsemestre = FormSemestre.query.get_or_404(formsemestre_id) if etudid: etud = models.Identite.query.get_or_404(etudid) diff --git a/sco_version.py b/sco_version.py index a8d3aae1..24931a73 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.6" +SCOVERSION = "9.2.7" SCONAME = "ScoDoc"