From 98b8a0a95af9788aa0563d25dd471862830c4280 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 8 Mar 2023 22:56:11 +0100 Subject: [PATCH] Ajout balises BUT pour bulletins PDF. Voir # 587 --- app/but/bulletin_but.py | 2 +- app/but/bulletin_but_xml_compat.py | 2 +- app/scodoc/sco_bulletins.py | 36 +++++++++++++++++---- app/scodoc/sco_bulletins_json.py | 2 +- app/scodoc/sco_bulletins_xml.py | 2 +- app/scodoc/sco_formsemestre_inscriptions.py | 2 +- app/scodoc/sco_page_etud.py | 3 +- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 9f0a9b85..ca0c4ead 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -501,7 +501,7 @@ class BulletinBUT: # --- Decision Jury infos, dpv = sco_bulletins.etud_descr_situation_semestre( etud.id, - self.res.formsemestre.id, + self.res.formsemestre, format="html", show_date_inscr=self.prefs["bul_show_date_inscr"], show_decisions=self.prefs["bul_show_decision"], diff --git a/app/but/bulletin_but_xml_compat.py b/app/but/bulletin_but_xml_compat.py index 98dc9741..74f5409c 100644 --- a/app/but/bulletin_but_xml_compat.py +++ b/app/but/bulletin_but_xml_compat.py @@ -253,7 +253,7 @@ def bulletin_but_xml_compat( ): infos, dpv = sco_bulletins.etud_descr_situation_semestre( etudid, - formsemestre_id, + formsemestre, format="xml", show_uevalid=sco_preferences.get_preference( "bul_show_uevalid", formsemestre_id diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 3fd15859..1c1694e0 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -42,8 +42,15 @@ from app import log from app.scodoc.sco_utils import json_error from app.but import bulletin_but from app.comp import res_sem +from app.comp.res_but import ResultatsSemestreBUT from app.comp.res_compat import NotesTableCompat -from app.models import Formation, FormSemestre, Identite, ModuleImplInscription +from app.models import ( + ApcParcours, + Formation, + FormSemestre, + Identite, + ModuleImplInscription, +) from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import AccessDenied, ScoValueError from app.scodoc import html_sco_header @@ -194,7 +201,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): # --- Decision Jury infos, dpv = etud_descr_situation_semestre( etudid, - formsemestre_id, + formsemestre, format="html", show_date_inscr=prefs["bul_show_date_inscr"], show_decisions=prefs["bul_show_decision"], @@ -686,7 +693,7 @@ def get_etud_rangs_groups( def etud_descr_situation_semestre( etudid, - formsemestre_id, + formsemestre: FormSemestre, ne="", format="html", # currently unused show_decisions=True, @@ -711,14 +718,13 @@ def etud_descr_situation_semestre( decisions_ue : noms (acronymes) des UE validées, séparées par des virgules. descr_decisions_ue : ' UE acquises: UE1, UE2', ou vide si pas de dec. ou si pas show_uevalid descr_mention : 'Mention Bien', ou vide si pas de mention ou si pas show_mention - descr_parcours : le nom (libelle) du parcours dans lequel est inscrit l'étudiant en BUT (vide ailleurs) + parcours_titre, parcours_code, refcomp_specialite, refcomp_specialite_long """ # Fonction utilisée par tous les bulletins (APC ou classiques) infos = collections.defaultdict(str) # --- Situation et décisions jury - - date_inscr, date_dem, date_def = _dates_insc_dem_def(etudid, formsemestre_id) + date_inscr, date_dem, date_def = _dates_insc_dem_def(etudid, formsemestre.id) if show_date_inscr: if not date_inscr: @@ -733,6 +739,22 @@ def etud_descr_situation_semestre( infos["descr_defaillance"] = "" + # Parcours BUT + infos["parcours_titre"] = "" + infos["parcours_code"] = "" + infos["refcomp_specialite"] = "" + infos["refcomp_specialite_long"] = "" + if formsemestre.formation.is_apc(): + res: ResultatsSemestreBUT = res_sem.load_formsemestre_results(formsemestre) + parcour: ApcParcours = ApcParcours.query.get(res.etuds_parcour_id[etudid]) + if parcour: + infos["parcours_titre"] = parcour.libelle or "" + infos["parcours_code"] = parcour.code or "" + refcomp = parcour.referentiel + if refcomp: + infos["refcomp_specialite"] = refcomp.specialite + infos["refcomp_specialite_long"] = refcomp.specialite_long + # Décision: valeurs par defaut vides: infos["decision_jury"] = infos["descr_decision_jury"] = "" infos["decision_sem"] = "" @@ -753,7 +775,7 @@ def etud_descr_situation_semestre( infos["date_defaillance"] = date_def infos["descr_decision_jury"] = f"Défaillant{ne}" - dpv = sco_pv_dict.dict_pvjury(formsemestre_id, etudids=[etudid]) + dpv = sco_pv_dict.dict_pvjury(formsemestre.id, etudids=[etudid]) if dpv: infos["decision_sem"] = dpv["decisions"][0]["decision_sem"] diff --git a/app/scodoc/sco_bulletins_json.py b/app/scodoc/sco_bulletins_json.py index 2d56eeb0..2239a21b 100644 --- a/app/scodoc/sco_bulletins_json.py +++ b/app/scodoc/sco_bulletins_json.py @@ -462,7 +462,7 @@ def dict_decision_jury( if prefs["bul_show_decision"] or with_decisions: infos, dpv = sco_bulletins.etud_descr_situation_semestre( etud.id, - formsemestre.id, + formsemestre, show_uevalid=prefs["bul_show_uevalid"], ) d["situation"] = infos["situation"] diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 96591cdb..923181d2 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -378,7 +378,7 @@ def make_xml_formsemestre_bulletinetud( ): infos, dpv = sco_bulletins.etud_descr_situation_semestre( etudid, - formsemestre_id, + formsemestre, format="xml", show_uevalid=sco_preferences.get_preference( "bul_show_uevalid", formsemestre_id diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 1e993a35..1d0a25ef 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -43,7 +43,7 @@ from app.models.validations import ScolarEvent import app.scodoc.sco_utils as scu from app import log from app.scodoc.scolog import logdb -from app.scodoc.sco_exceptions import ScoException, ScoValueError +from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.codes_cursus import UE_STANDARD, UE_SPORT, UE_TYPE_NAME import app.scodoc.notesdb as ndb from app.scodoc.TrivialFormulator import TrivialFormulator diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index d821746c..218d459d 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -239,9 +239,10 @@ def ficheEtud(etudid=None): sem_info = {} for sem in info["sems"]: if sem["ins"]["etat"] != scu.INSCRIT: + formsemestre: FormSemestre = FormSemestre.query.get(sem["formsemestre_id"]) descr, _ = etud_descr_situation_semestre( etudid, - sem["formsemestre_id"], + formsemestre, info["ne"], show_date_inscr=False, )