Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
4 changed files with 34 additions and 9 deletions
Showing only changes of commit 6d3f276cc0 - Show all commits

View File

@ -499,10 +499,8 @@ class BulletinBUT:
d["etud"]["etat_civil"] = etud.etat_civil d["etud"]["etat_civil"] = etud.etat_civil
d.update(self.res.sem) d.update(self.res.sem)
etud_etat = self.res.get_etud_etat(etud.id) etud_etat = self.res.get_etud_etat(etud.id)
d["filigranne"] = sco_bulletins_pdf.get_filigranne( d["filigranne"] = sco_bulletins_pdf.get_filigranne_apc(
etud_etat, etud_etat, self.prefs, etud.id, res=self.res
self.prefs,
decision_sem=d["semestre"].get("decision"),
) )
if etud_etat == scu.DEMISSION: if etud_etat == scu.DEMISSION:
d["demission"] = "(Démission)" d["demission"] = "(Démission)"

View File

@ -35,6 +35,7 @@ from app.decorators import (
permission_required, permission_required,
) )
from app.models import FormSemestre, FormSemestreInscription, Identite from app.models import FormSemestre, FormSemestreInscription, Identite
from app.scodoc import sco_bulletins_pdf
from app.scodoc.codes_cursus import UE_STANDARD from app.scodoc.codes_cursus import UE_STANDARD
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError
from app.scodoc.sco_logos import find_logo from app.scodoc.sco_logos import find_logo
@ -104,8 +105,10 @@ def _build_bulletin_but_infos(
bulletins_sem = BulletinBUT(formsemestre) bulletins_sem = BulletinBUT(formsemestre)
if fmt == "pdf": if fmt == "pdf":
bul: dict = bulletins_sem.bulletin_etud_complet(etud) bul: dict = bulletins_sem.bulletin_etud_complet(etud)
filigranne = bul["filigranne"]
else: # la même chose avec un peu moins d'infos else: # la même chose avec un peu moins d'infos
bul: dict = bulletins_sem.bulletin_etud(etud, force_publishing=True) bul: dict = bulletins_sem.bulletin_etud(etud, force_publishing=True)
filigranne = ""
decision_ues = ( decision_ues = (
{x["acronyme"]: x for x in bul["semestre"]["decision_ue"]} {x["acronyme"]: x for x in bul["semestre"]["decision_ue"]}
if "semestre" in bul and "decision_ue" in bul["semestre"] if "semestre" in bul and "decision_ue" in bul["semestre"]
@ -131,6 +134,7 @@ def _build_bulletin_but_infos(
"decision_ues": decision_ues, "decision_ues": decision_ues,
"ects_total": ects_total, "ects_total": ects_total,
"etud": etud, "etud": etud,
"filigranne": filigranne,
"formsemestre": formsemestre, "formsemestre": formsemestre,
"logo": logo, "logo": logo,
"prefs": bulletins_sem.prefs, "prefs": bulletins_sem.prefs,

View File

@ -48,6 +48,7 @@ def make_bulletin_but_court_pdf(
ects_total: float = 0.0, ects_total: float = 0.0,
etud: Identite = None, etud: Identite = None,
formsemestre: FormSemestre = None, formsemestre: FormSemestre = None,
filigranne=""
logo: Logo = None, logo: Logo = None,
prefs: SemPreferences = None, prefs: SemPreferences = None,
title: str = "", title: str = "",
@ -86,6 +87,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
decision_ues: dict = None, decision_ues: dict = None,
ects_total: float = 0.0, ects_total: float = 0.0,
etud: Identite = None, etud: Identite = None,
filigranne="",
formsemestre: FormSemestre = None, formsemestre: FormSemestre = None,
logo: Logo = None, logo: Logo = None,
prefs: SemPreferences = None, prefs: SemPreferences = None,
@ -95,7 +97,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
] = None, ] = None,
ues_acronyms: list[str] = None, ues_acronyms: list[str] = None,
): ):
super().__init__(bul, authuser=current_user) super().__init__(bul, authuser=current_user, filigranne=filigranne)
self.bul = bul self.bul = bul
self.cursus = cursus self.cursus = cursus
self.decision_ues = decision_ues self.decision_ues = decision_ues

View File

@ -60,6 +60,7 @@ import traceback
from flask import g, request from flask import g, request
from app import log, ScoValueError from app import log, ScoValueError
from app.comp.res_but import ResultatsSemestreBUT
from app.models import FormSemestre, Identite from app.models import FormSemestre, Identite
from app.scodoc import sco_cache from app.scodoc import sco_cache
from app.scodoc import codes_cursus from app.scodoc import codes_cursus
@ -318,14 +319,34 @@ def get_etud_bulletins_pdf(etudid, version="selectedevals"):
return pdfdoc, filename return pdfdoc, filename
def get_filigranne(etud_etat: str, prefs, decision_sem=None) -> str: def get_filigranne(
"""Texte à placer en "filigranne" sur le bulletin pdf""" etud_etat: str, prefs, decision_sem: str | None | bool = None
) -> str:
"""Texte à placer en "filigranne" sur le bulletin pdf.
etud_etat : etat de l'inscription (I ou D)
decision_sem = code jury ou vide
"""
if etud_etat == scu.DEMISSION: if etud_etat == scu.DEMISSION:
return "Démission" return "Démission"
elif etud_etat == codes_cursus.DEF: if etud_etat == codes_cursus.DEF:
return "Défaillant" return "Défaillant"
elif (prefs["bul_show_temporary"] and not decision_sem) or prefs[ if (prefs["bul_show_temporary"] and not decision_sem) or prefs[
"bul_show_temporary_forced" "bul_show_temporary_forced"
]: ]:
return prefs["bul_temporary_txt"] return prefs["bul_temporary_txt"]
return "" return ""
def get_filigranne_apc(
etud_etat: str, prefs, etudid: int, res: ResultatsSemestreBUT
) -> str:
"""Texte à placer en "filigranne" sur le bulletin pdf.
Version optimisée pour BUT
"""
if prefs["bul_show_temporary_forced"]:
return get_filigranne(etud_etat, prefs)
if prefs["bul_show_temporary"]:
# requete les décisions de jury
decision_sem = res.etud_has_decision(etudid)
return get_filigranne(etud_etat, prefs, decision_sem=decision_sem)
return get_filigranne(etud_etat, prefs)