From 466b6fc3ae7a2062f6976cf6b002770ed2c5a3ea Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 7 Dec 2022 20:06:01 +0100 Subject: [PATCH] Corrige annulation dispense d'UE APC --- app/scodoc/sco_formsemestre_status.py | 4 +++- app/scodoc/sco_moduleimpl.py | 2 +- app/views/notes.py | 27 ++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index e8ae30a994..ae7f29bdb0 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -263,7 +263,9 @@ def formsemestre_status_menubar(formsemestre: FormSemestre) -> str: menu_inscriptions = [ { - "title": "Voir les inscriptions aux modules", + "title": "Gérer les inscriptions aux UE et modules" + if formsemestre.formation.is_apc() + else "Gérer les inscriptions aux modules", "endpoint": "notes.moduleimpl_inscriptions_stats", "args": {"formsemestre_id": formsemestre_id}, } diff --git a/app/scodoc/sco_moduleimpl.py b/app/scodoc/sco_moduleimpl.py index 97fb7df067..cdce8ac470 100644 --- a/app/scodoc/sco_moduleimpl.py +++ b/app/scodoc/sco_moduleimpl.py @@ -277,7 +277,7 @@ def do_moduleimpl_inscription_create(args, formsemestre_id=None): except psycopg2.errors.UniqueViolation as exc: raise ScoValueError( "Inscription impossible car déjà existante: vérifiez la situation" - ) + ) from exc sco_cache.invalidate_formsemestre( formsemestre_id=formsemestre_id ) # > moduleimpl_inscription diff --git a/app/views/notes.py b/app/views/notes.py index f7e5473ff2..6ba9bf92cb 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1620,12 +1620,29 @@ def etud_desinscrit_ue(etudid, formsemestre_id, ue_id): @permission_required(Permission.ScoEtudInscrit) @scodoc7func def etud_inscrit_ue(etudid, formsemestre_id, ue_id): - """Inscrit l'etudiant de tous les modules de cette UE dans ce semestre.""" - sco_moduleimpl_inscriptions.do_etud_inscrit_ue(etudid, formsemestre_id, ue_id) + """ + En classic: inscrit l'étudiant à tous les modules de cette UE dans ce semestre. + En APC: enlève la dispense de cette UE s'il y en a une. + """ + formsemestre = FormSemestre.query.filter_by( + id=formsemestre_id, dept_id=g.scodoc_dept_id + ).first_or_404() + etud = Identite.query.get_or_404(etudid) + ue = UniteEns.query.get_or_404(ue_id) + if ue.formation.is_apc(): + for disp in DispenseUE.query.filter_by(etudid=etud.id, ue_id=ue_id): + db.session.delete(disp) + db.session.commit() + sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre.id) + else: + # Formations classiques: joue sur les inscriptions aux modules + sco_moduleimpl_inscriptions.do_etud_inscrit_ue(etud.id, formsemestre_id, ue_id) return flask.redirect( - scu.ScoURL() - + "/Notes/moduleimpl_inscriptions_stats?formsemestre_id=" - + str(formsemestre_id) + url_for( + "notes.moduleimpl_inscriptions_stats", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) )