From 9f0bcbc937fa9e780a5744239e028cae8923d11c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 7 Jan 2025 13:52:01 +0100 Subject: [PATCH] Fix create modules / tests ok. --- app/models/modules.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/modules.py b/app/models/modules.py index 7c7a38203..6adba8d50 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -228,9 +228,11 @@ class Module(models.ScoDocModel): formation = data.get("formation") if formation is None or not isinstance(formation, Formation): raise ScoValueError("Module.create_from_dict: formation missing") - else: # check ue_id - formation = UniteEns.get_ue(data["ue_id"]) - # formation = Formation.get_formation(data["formation_id"]) + else: + formation = Formation.get_formation(data["formation_id"]) + # + if ue.formation_id != formation.id: + raise ScoValueError("Module.create_from_dict: UE not in formation") # refuse de créer un module APC avec semestres semestre du module != semestre de l'UE if formation.is_apc(): if int(data.get("semestre_id", 1)) != ue.semestre_idx: