From 47682e54d208912e3c70d8479911520a3289c040 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 27 Sep 2022 09:24:00 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20tableau=20indicateurs=20BUT=20(?= =?UTF-8?q?bacs=20S1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/jury_but.py | 2 +- app/scodoc/sco_report_but.py | 29 ++++++++++++++++++++--------- sco_version.py | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/but/jury_but.py b/app/but/jury_but.py index a889c57da..6d3344c3d 100644 --- a/app/but/jury_but.py +++ b/app/but/jury_but.py @@ -904,7 +904,7 @@ class DecisionsProposeesUE(DecisionsProposees): etud=etud, code_valide=self.validation.code if self.validation is not None else None, ) - log(f"built {self}") + # log(f"built {self}") self.formsemestre = formsemestre self.ue: UniteEns = ue self.rcue: RegroupementCoherentUE = None diff --git a/app/scodoc/sco_report_but.py b/app/scodoc/sco_report_but.py index ea042f5b6..a4fbf3e26 100644 --- a/app/scodoc/sco_report_but.py +++ b/app/scodoc/sco_report_but.py @@ -84,6 +84,10 @@ def formsemestre_but_indicateurs(formsemestre_id: int, format="html"): row["titre_indicateur"] = titre_indicateur rows.append(row) + # ensure Total is the rightmost column + del bacs[bacs.index("Total")] + bacs.append("Total") + tab = GenTable( titles={bac: bac for bac in bacs}, columns_ids=["titre_indicateur"] + bacs, @@ -172,15 +176,17 @@ def but_indicateurs_by_bac(formsemestre: FormSemestre) -> dict[str:dict]: if len(formsemestre_id_precedents) == 1 else formsemestre_impair.session_id() ) - indicateurs_by_bac["Total"].update( - _indicateurs_enquete_but_inscrits(formsemestre_impair.inscriptions, suffix) - ) for bac, inscriptions in _formsemestre_inscriptions_by_bac( formsemestre_impair ).items(): + if bac not in indicateurs_by_bac: + indicateurs_by_bac[bac] = defaultdict(lambda: 0) indicateurs_by_bac[bac].update( _indicateurs_enquete_but_inscrits(inscriptions, suffix) ) + indicateurs_by_bac["Total"].update( + _indicateurs_enquete_but_inscrits(formsemestre_impair.inscriptions, suffix) + ) return indicateurs_by_bac @@ -201,12 +207,17 @@ def _indicateurs_enquete_but_inscrits( Suffixe les clés avec _suffix""" if suffix: suffix = "_" + suffix - return { - "nb_inscr" + suffix: len(inscriptions), - "nb_actifs" + suffix: len([i for i in inscriptions if i.etat == scu.INSCRIT]), - "nb_def" + suffix: len([i for i in inscriptions if i.etat == scu.DEF]), - "nb_dem" + suffix: len([i for i in inscriptions if i.etat == scu.DEMISSION]), - } + return defaultdict( + lambda: "?", + { + "nb_inscr" + suffix: len(inscriptions), + "nb_actifs" + + suffix: len([i for i in inscriptions if i.etat == scu.INSCRIT]), + "nb_def" + suffix: len([i for i in inscriptions if i.etat == scu.DEF]), + "nb_dem" + + suffix: len([i for i in inscriptions if i.etat == scu.DEMISSION]), + }, + ) def _indicateurs_enquete_but( diff --git a/sco_version.py b/sco_version.py index ff69c1812..23d862362 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.45" +SCOVERSION = "9.3.46" SCONAME = "ScoDoc"