From a4f24b81a8a6621b5e3c070ccfc7f567017b4fb5 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 6 Feb 2023 10:13:01 +0100 Subject: [PATCH] =?UTF-8?q?Interdit=20modification=20coefs=20APC=20si=20se?= =?UTF-8?q?ms=20verrouill=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/modules.py | 7 +++++++ app/scodoc/sco_edit_ue.py | 2 +- app/views/pn_modules.py | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/models/modules.py b/app/models/modules.py index d4c70c038..c0bb84ac7 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -6,6 +6,7 @@ from app.models import APO_CODE_STR_LEN from app.models.but_refcomp import ApcParcours, app_critiques_modules, parcours_modules from app.scodoc import sco_utils as scu from app.scodoc.sco_codes_parcours import UE_SPORT +from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_utils import ModuleType @@ -175,6 +176,8 @@ class Module(db.Model): ue_coef_dict = { ue_id : coef } Les coefs nuls (zéro) ne sont pas stockés: la relation est supprimée. """ + if self.formation.has_locked_sems(): + raise ScoValueError("Formation verrouillée") changed = False for ue_id, coef in ue_coef_dict.items(): # Existant ? @@ -201,6 +204,8 @@ class Module(db.Model): def update_ue_coef_dict(self, ue_coef_dict: dict): """update coefs vers UE (ajoute aux existants)""" + if self.formation.has_locked_sems(): + raise ScoValueError("Formation verrouillée") current = self.get_ue_coef_dict() current.update(ue_coef_dict) self.set_ue_coef_dict(current) @@ -211,6 +216,8 @@ class Module(db.Model): def delete_ue_coef(self, ue): """delete coef""" + if self.formation.has_locked_sems(): + raise ScoValueError("Formation verrouillée") ue_coef = ModuleUECoef.query.get((self.id, ue.id)) if ue_coef: db.session.delete(ue_coef) diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 906493a2a..576319fa0 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -811,7 +811,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours); f"""
  • Éditer les coefficients des ressources et SAÉs + }">{'Visualiser' if locked else 'Éditer'} les coefficients des ressources et SAÉs
  • """ diff --git a/app/views/pn_modules.py b/app/views/pn_modules.py index 6868b8bd5..e12c07f48 100644 --- a/app/views/pn_modules.py +++ b/app/views/pn_modules.py @@ -165,7 +165,7 @@ def set_module_ue_coef(): coef = float(request.form["coef"].replace(",", ".")) except ValueError: return scu.json_error(404, "invalid coef") - module = models.Module.query.get(module_id) + module: Module = models.Module.query.get(module_id) if module is None: return scu.json_error(404, f"module not found ({module_id})") ue = models.UniteEns.query.get(ue_id) @@ -229,7 +229,8 @@ def edit_modules_ue_coefs(): "notes.set_module_ue_coef", scodoc_dept=g.scodoc_dept, ), - read_only=not current_user.has_permission(Permission.ScoChangeFormation), + read_only=locked + or not current_user.has_permission(Permission.ScoChangeFormation), semestre_idx=semestre_idx, semestre_ids=range(1, formation.get_parcours().NB_SEM + 1), parcours_id=parcours_id,