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: