From e0188ebc2d614c36955014a432e9eb333022bae3 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 10 Aug 2023 19:08:01 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20calcul=20de=20la=20liste=20des=20niveaux?= =?UTF-8?q?=20associ=C3=A9s=20=C3=A0=20une=20ann=C3=A9e=20de=20parcours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/but_refcomp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/but_refcomp.py b/app/models/but_refcomp.py index 2cb1145d7..73ddf9f7a 100644 --- a/app/models/but_refcomp.py +++ b/app/models/but_refcomp.py @@ -471,9 +471,16 @@ class ApcNiveau(db.Model, XMLModel): for pn in parcour_niveaux ] else: - niveaux: list[ApcNiveau] = competence.niveaux.filter_by( - annee=f"BUT{int(annee)}" - ).all() + niveaux: list[ApcNiveau] = ( + ApcNiveau.query.filter_by(annee=f"BUT{int(annee)}") + .join(ApcCompetence) + .filter_by(id=competence.id) + .join(ApcParcoursNiveauCompetence) + .filter(ApcParcoursNiveauCompetence.niveau == ApcNiveau.ordre) + .join(ApcAnneeParcours) + .filter_by(parcours_id=parcour.id) + .all() + ) _cache[key] = niveaux return niveaux