From 1b297580c9a26f0239fa791213af6e20d51979d4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 17 Jul 2023 15:09:17 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20changement=20de=20r=C3=A9f=C3=A9rentiel?= =?UTF-8?q?=20de=20comp=C3=A9tences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_formation_versions.py | 2 +- app/views/refcomp.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/scodoc/sco_formation_versions.py b/app/scodoc/sco_formation_versions.py index e4a5937e..8ffcb39c 100644 --- a/app/scodoc/sco_formation_versions.py +++ b/app/scodoc/sco_formation_versions.py @@ -224,7 +224,7 @@ def do_formsemestres_associate_new_version( _reassociate_moduleimpls(formsemestre, ues_old2new, modules_old2new) db.session.commit() - return formation_id + return new_formation_id def _reassociate_moduleimpls( diff --git a/app/views/refcomp.py b/app/views/refcomp.py index cbf13a06..a7f5edfb 100644 --- a/app/views/refcomp.py +++ b/app/views/refcomp.py @@ -149,10 +149,14 @@ def refcomp_assoc_formation(formation_id: int): db.session.get(ApcReferentielCompetences, referentiel_competence_id) is not None ) - formation.referentiel_competence_id = referentiel_competence_id - db.session.add(formation) - db.session.commit() - flash("nouveau référentiel de compétences associé") + if formation.referentiel_competence_id != referentiel_competence_id: + formation.refcomp_desassoc() + formation.referentiel_competence_id = referentiel_competence_id + db.session.add(formation) + db.session.commit() + flash("Nouveau référentiel de compétences associé") + else: + flash("Pas de changements") return redirect( url_for( "notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation_id @@ -172,7 +176,7 @@ def refcomp_assoc_formation(formation_id: int): @permission_required(Permission.ScoChangeFormation) def refcomp_desassoc_formation(formation_id: int): """Désassocie la formation de son ref. de compétence""" - formation = Formation.query.get_or_404(formation_id) + formation: Formation = Formation.query.get_or_404(formation_id) formation.refcomp_desassoc() return redirect( url_for("notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation.id)