From 02a5b00ecf73bbf1311972a1cc48bd7922f89a38 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 2 Jun 2024 12:05:01 +0200 Subject: [PATCH] =?UTF-8?q?Changement=20r=C3=A9f.=20comp.=20=C3=A9quivalen?= =?UTF-8?q?t:=20SD=20<>=20STID.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/but_refcomp.py | 8 ++++++++ app/views/refcomp.py | 4 +++- ressources/referentiels/equivalences.yaml | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/models/but_refcomp.py b/app/models/but_refcomp.py index 22d40785a..6831f0925 100644 --- a/app/models/but_refcomp.py +++ b/app/models/but_refcomp.py @@ -274,6 +274,11 @@ class ApcReferentielCompetences(db.Model, XMLModel): return "type_departement mismatch" # Table d'équivalences entre refs: equiv = self._load_config_equivalences() + # Même specialité (ou alias) ? + if self.specialite != other.specialite and other.specialite not in equiv.get( + "alias", [] + ): + return "specialite mismatch" # mêmes parcours ? eq_parcours = equiv.get("parcours", {}) parcours_by_code_1 = {eq_parcours.get(p.code, p.code): p for p in self.parcours} @@ -317,6 +322,9 @@ class ApcReferentielCompetences(db.Model, XMLModel): def _load_config_equivalences(self) -> dict: """Load config file ressources/referentiels/equivalences.yaml used to define equivalences between distinct referentiels + return a dict, with optional keys: + alias: list of equivalent names for speciality (eg SD == STID) + parcours: dict with equivalent parcours acronyms """ try: with open(REFCOMP_EQUIVALENCE_FILENAME, encoding="utf-8") as f: diff --git a/app/views/refcomp.py b/app/views/refcomp.py index 42193d7cf..bf4bd9f4a 100644 --- a/app/views/refcomp.py +++ b/app/views/refcomp.py @@ -56,7 +56,9 @@ def refcomp(refcomp_id): @permission_required(Permission.ScoView) def refcomp_show(refcomp_id): """Affichage du référentiel de compétences.""" - referentiel_competence = ApcReferentielCompetences.query.get_or_404(refcomp_id) + referentiel_competence: ApcReferentielCompetences = ( + ApcReferentielCompetences.query.get_or_404(refcomp_id) + ) # Autres référentiels "équivalents" pour proposer de changer les formations: referentiels_equivalents = referentiel_competence.equivalents() return render_template( diff --git a/ressources/referentiels/equivalences.yaml b/ressources/referentiels/equivalences.yaml index d7ac623e5..097a2f8e0 100644 --- a/ressources/referentiels/equivalences.yaml +++ b/ressources/referentiels/equivalences.yaml @@ -15,4 +15,10 @@ QLIO: # la clé est 'specialite' ATN: MTD # competences: # titres de compétences ('nom_court' dans le XML) -SD: STID +STID: # passage de STID à SD + alias: + - SD + +SD: # pour revenir en arrière au besoin + alias: + - STID