diff --git a/app/models/departements.py b/app/models/departements.py index ebe5cc14..44a963ca 100644 --- a/app/models/departements.py +++ b/app/models/departements.py @@ -55,6 +55,9 @@ def create_dept(acronym: str, visible=True) -> Departement: "Create new departement" from app.models import ScoPreference + existing = Departement.query.filter_by(acronym=acronym).count() + if existing: + raise ValueError(f"acronyme {acronym} déjà existant") departement = Departement(acronym=acronym, visible=visible) p1 = ScoPreference(name="DeptName", value=acronym, departement=departement) db.session.add(p1)