From 0d638de2090ea229e6ade3bf5c110623140c819d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 10 May 2022 17:56:21 +0200 Subject: [PATCH] Fix: UE delete --- app/scodoc/sco_edit_ue.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index fd25e5da3f..4c0a8ef59f 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -156,6 +156,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): from app.scodoc import sco_parcours_dut ue = UniteEns.query.get_or_404(ue_id) + formation_id = ue.formation_id + semestre_idx = ue.semestre_idx if not can_delete_ue(ue): raise ScoNonEmptyFormationObject( "UE", @@ -163,8 +165,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): dest_url=url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, - formation_id=ue.formation_id, - semestre_idx=ue.semestre_idx, + formation_id=formation_id, + semestre_idx=semestre_idx, ), ) @@ -187,13 +189,13 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): cancel_url=url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, - formation_id=ue.formation_id, - semestre_idx=ue.semestre_idx, + formation_id=formation_id, + semestre_idx=semestre_idx, ), parameters={"ue_id": ue.id, "dialog_confirmed": 1}, ) if delete_validations: - log("deleting all validations of UE %s" % ue.id) + log(f"deleting all validations of UE {ue.id}") ndb.SimpleQuery( "DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s", {"ue_id": ue.id}, @@ -215,10 +217,10 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): # utilisé: acceptable de tout invalider): sco_cache.invalidate_formsemestre() # news - F = sco_formations.formation_list(args={"formation_id": ue.formation_id})[0] + F = sco_formations.formation_list(args={"formation_id": formation_id})[0] ScolarNews.add( typ=ScolarNews.NEWS_FORM, - obj=ue.formation_id, + obj=formation_id, text=f"Modification de la formation {F['acronyme']}", max_frequency=10 * 60, ) @@ -228,8 +230,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False): url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, - formation_id=ue.formation_id, - semestre_idx=ue.semestre_idx, + formation_id=formation_id, + semestre_idx=semestre_idx, ) ) return None