From 814a8dbc2426ede18921f6cc1bf97393bd61b1e9 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 30 Sep 2021 17:50:37 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20qq=20msg=20d'erreur=20+=20lien?= =?UTF-8?q?=20formsemestre=5Fstatus=20vers=20listes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins.py | 7 +++--- app/scodoc/sco_edit_ue.py | 1 + app/scodoc/sco_formsemestre.py | 14 ++++++----- app/scodoc/sco_formsemestre_status.py | 34 +++++++++++++++++++-------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 7d1859a22..0a88f648a 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -136,7 +136,8 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): prefs = sco_preferences.SemPreferences(formsemestre_id) nt = sco_cache.NotesTableCache.get(formsemestre_id) # > toutes notes - + if not nt.get_etud_etat(etudid): + raise ScoValueError("Etudiant non inscrit à ce semestre") I = scu.DictDefault(defaultvalue="") I["etudid"] = etudid I["formsemestre_id"] = formsemestre_id @@ -774,8 +775,8 @@ def formsemestre_bulletinetud( except: sco_etud.log_unknown_etud() raise ScoValueError("étudiant inconnu") - - sem = sco_formsemestre.get_formsemestre(formsemestre_id) + # API, donc erreurs admises en ScoValueError + sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True) bulletin = do_formsemestre_bulletinetud( formsemestre_id, diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index a5509a28e..dc1b4f84e 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -845,6 +845,7 @@ def ue_sharing_code(ue_code=None, ue_id=None, hide_ue_id=None): """ from app.scodoc import sco_formations + ue_code = str(ue_code) if ue_id: ue = do_ue_list(args={"ue_id": ue_id})[0] if not ue_code: diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 40355120b..2cb9d6770 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -93,16 +93,18 @@ _formsemestreEditor = ndb.EditableTable( ) -def get_formsemestre(formsemestre_id): +def get_formsemestre(formsemestre_id, raise_soft_exc=False): "list ONE formsemestre" if not isinstance(formsemestre_id, int): raise ValueError("formsemestre_id must be an integer !") - try: - sem = do_formsemestre_list(args={"formsemestre_id": formsemestre_id})[0] - return sem - except: + sems = do_formsemestre_list(args={"formsemestre_id": formsemestre_id}) + if not sems: log("get_formsemestre: invalid formsemestre_id (%s)" % formsemestre_id) - raise + if raise_soft_exc: + raise ScoValueError(f"semestre {formsemestre_id} inconnu !") + else: + raise ValueError(f"semestre {formsemestre_id} inconnu !") + return sems[0] def do_formsemestre_list(*a, **kw): diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index e85fd4a3d..fe8decb00 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -505,15 +505,29 @@ def formsemestre_page_title(): fill_formsemestre(sem) - H = [ - """
""", - """""" - % sem, - formsemestre_status_menubar(sem), - """
""", - ] - return "\n".join(H) + h = f"""
+ + {formsemestre_status_menubar(sem)} +
+ """ + + return h def fill_formsemestre(sem): @@ -967,7 +981,7 @@ def formsemestre_status(formsemestre_id=None): """Tableau de bord semestre HTML""" # porté du DTML cnx = ndb.GetDBConnexion() - sem = sco_formsemestre.get_formsemestre(formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True) Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list( formsemestre_id=formsemestre_id )