From 37fde88a74e8f04d5eb5bafe41bad478c0d3573a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 14 Feb 2022 13:55:07 +0100 Subject: [PATCH] Fix: exc. inscriptions en doublon, bul xml compat but --- app/but/bulletin_but_xml_compat.py | 26 ++++++++++++++++---------- app/scodoc/sco_moduleimpl.py | 8 +++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/but/bulletin_but_xml_compat.py b/app/but/bulletin_but_xml_compat.py index 1369eb672..73e06c4de 100644 --- a/app/but/bulletin_but_xml_compat.py +++ b/app/but/bulletin_but_xml_compat.py @@ -220,17 +220,23 @@ def bulletin_but_xml_compat( note_max_origin=str(e.note_max), ) x_mod.append(x_eval) - x_eval.append( - Element( - "note", - value=scu.fmt_note( - results.modimpls_results[ - e.moduleimpl_id - ].evals_notes[e.id][etud.id], - note_max=e.note_max, - ), + try: + x_eval.append( + Element( + "note", + value=scu.fmt_note( + results.modimpls_results[ + e.moduleimpl_id + ].evals_notes[e.id][etud.id], + note_max=e.note_max, + ), + ) ) - ) + except KeyError: + x_eval.append( + Element("note", value="", note_max="") + ) + # XXX TODO: Evaluations incomplètes ou futures: XXX # XXX TODO UE capitalisee (listee seulement si meilleure que l'UE courante) diff --git a/app/scodoc/sco_moduleimpl.py b/app/scodoc/sco_moduleimpl.py index 38db492d5..e0dab5f42 100644 --- a/app/scodoc/sco_moduleimpl.py +++ b/app/scodoc/sco_moduleimpl.py @@ -29,6 +29,7 @@ """ from flask_login import current_user +import psycopg2 import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb @@ -271,7 +272,12 @@ _moduleimpl_inscriptionEditor = ndb.EditableTable( def do_moduleimpl_inscription_create(args, formsemestre_id=None): "create a moduleimpl_inscription" cnx = ndb.GetDBConnexion() - r = _moduleimpl_inscriptionEditor.create(cnx, args) + try: + r = _moduleimpl_inscriptionEditor.create(cnx, args) + except psycopg2.errors.UniqueViolation as exc: + raise ScoValueError( + "Inscription impossible car déjà existante: vérifiez la situation" + ) sco_cache.invalidate_formsemestre( formsemestre_id=formsemestre_id ) # > moduleimpl_inscription