From 4bec9a1713ec1a43d6dd1169a1be0093f53deb6e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 5 Sep 2022 13:54:35 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20cas=20une=20seule=20UE=20capitalis=C3=A9?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/bulletin_but.py | 2 +- app/comp/res_common.py | 12 +++++++++--- app/comp/res_compat.py | 14 ++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 4478a710..a06e771f 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -152,7 +152,7 @@ class BulletinBUT: return {} # aucune capitalisation d = {} for _, ue_capitalisee in self.res.validations.ue_capitalisees.loc[ - etud.id + [etud.id] ].iterrows(): if sco_codes_parcours.code_ue_validant(ue_capitalisee.code): ue = UniteEns.query.get(ue_capitalisee.ue_id) # XXX cacher ? diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 6df76359..d43f597e 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -16,8 +16,9 @@ import pandas as pd from flask import g, url_for from app.auth.models import User -from app.comp.res_cache import ResultatsCache from app.comp import res_sem +from app.comp.res_cache import ResultatsCache +from app.comp.jury import ValidationsSemestre from app.comp.moy_mod import ModuleImplResults from app.models import FormSemestre, FormSemestreUECoef from app.models import Identite @@ -171,6 +172,12 @@ class ResultatsSemestre(ResultatsCache): ] # --- JURY... + def load_validations(self) -> ValidationsSemestre: + """Load validations, set attribute and return value""" + if not self.validations: + self.validations = res_sem.load_formsemestre_validations(self.formsemestre) + return self.validations + def get_etud_ue_validables(self, etudid: int) -> list[UniteEns]: """Liste des UEs du semestre qui doivent être validées @@ -229,8 +236,7 @@ class ResultatsSemestre(ResultatsCache): """ # Supposant qu'il y a peu d'UE capitalisées, # on recalcule les moyennes gen des etuds ayant des UE capitalisée. - if not self.validations: - self.validations = res_sem.load_formsemestre_validations(self.formsemestre) + self.load_validations() ue_capitalisees = self.validations.ue_capitalisees for etudid in ue_capitalisees.index: recompute_mg = False diff --git a/app/comp/res_compat.py b/app/comp/res_compat.py index 99bda62f..fb8ba7f8 100644 --- a/app/comp/res_compat.py +++ b/app/comp/res_compat.py @@ -284,11 +284,8 @@ class NotesTableCompat(ResultatsSemestre): if self.get_etud_etat(etudid) == DEF: return {} else: - if not self.validations: - self.validations = res_sem.load_formsemestre_validations( - self.formsemestre - ) - return self.validations.decisions_jury_ues.get(etudid, None) + validations = self.load_validations() + return validations.decisions_jury_ues.get(etudid, None) def get_etud_ects_valides(self, etudid: int, decisions_ues: dict = False) -> 0: """Le total des ECTS validés (et enregistrés) par l'étudiant dans ce semestre. @@ -314,11 +311,8 @@ class NotesTableCompat(ResultatsSemestre): "compense_formsemestre_id": None, } else: - if not self.validations: - self.validations = res_sem.load_formsemestre_validations( - self.formsemestre - ) - return self.validations.decisions_jury.get(etudid, None) + validations = self.load_validations() + return validations.decisions_jury.get(etudid, None) def get_etud_mat_moy(self, matiere_id: int, etudid: int) -> str: """moyenne d'un étudiant dans une matière (ou NA si pas de notes)"""