2023-08-02 00:13:31 +02:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Génération bulletin BUT synthétique en une page
|
|
|
|
|
|
|
|
On génère du HTML. Il sera si possible traduit en PDF par weasyprint.
|
|
|
|
|
|
|
|
Le HTML est lui même généré à partir d'un template Jinja.
|
|
|
|
|
|
|
|
## Données
|
|
|
|
|
|
|
|
Ces données sont des objets passés au template.
|
|
|
|
|
|
|
|
- `etud: Identite` : l'étudiant
|
|
|
|
- `formsemestre: FormSemestre` : le formsemestre d'où est émis ce bulletin
|
|
|
|
- `bulletins_sem: BulletinBUT` les données bulletins pour tous les étudiants
|
|
|
|
- `bul: dict` : le bulletin (dict, même structure que le json publié)
|
|
|
|
- `cursus: EtudCursusBUT`: infos sur le cursus BUT (niveaux validés etc)
|
|
|
|
- `decision_ues: dict`: `{ acronyme_ue : { 'code' : 'ADM' }}` accès aux décisions
|
|
|
|
de jury d'UE
|
|
|
|
- `ects_total` : nombre d'ECTS validées dans ce cursus
|
|
|
|
- `ue_validation_by_niveau : dict` : les validations d'UE de chaque niveau du cursus
|
|
|
|
"""
|
|
|
|
import datetime
|
|
|
|
import time
|
|
|
|
|
|
|
|
from flask import render_template, url_for
|
|
|
|
from flask import g, request
|
|
|
|
|
|
|
|
from app.but.bulletin_but import BulletinBUT
|
|
|
|
from app.but import cursus_but, validations_view
|
|
|
|
from app.decorators import (
|
|
|
|
scodoc,
|
|
|
|
permission_required,
|
|
|
|
)
|
|
|
|
from app.models import FormSemestre, FormSemestreInscription, Identite
|
|
|
|
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences
|
|
|
|
from app.scodoc.sco_logos import find_logo
|
|
|
|
from app.scodoc.sco_permissions import Permission
|
|
|
|
from app.views import notes_bp as bp
|
|
|
|
from app.views import ScoData
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/bulletin_but/<int:formsemestre_id>/<int:etudid>")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def bulletin_but(formsemestre_id: int, etudid: int = None):
|
|
|
|
"""Page HTML affichant le bulletin BUT simplifié"""
|
|
|
|
etud: Identite = Identite.query.get_or_404(etudid)
|
|
|
|
formsemestre: FormSemestre = (
|
|
|
|
FormSemestre.query.filter_by(id=formsemestre_id)
|
|
|
|
.join(FormSemestreInscription)
|
|
|
|
.filter_by(etudid=etudid)
|
|
|
|
.first_or_404()
|
|
|
|
)
|
|
|
|
bulletins_sem = BulletinBUT(formsemestre)
|
|
|
|
bul = bulletins_sem.bulletin_etud(etud, formsemestre) # dict
|
|
|
|
decision_ues = {x["acronyme"]: x for x in bul["semestre"]["decision_ue"]}
|
|
|
|
cursus = cursus_but.EtudCursusBUT(etud, formsemestre.formation)
|
|
|
|
refcomp = formsemestre.formation.referentiel_competence
|
|
|
|
if refcomp is None:
|
|
|
|
raise ScoNoReferentielCompetences(formation=formsemestre.formation)
|
|
|
|
ue_validation_by_niveau = validations_view.get_ue_validation_by_niveau(
|
|
|
|
refcomp, etud
|
|
|
|
)
|
|
|
|
ects_total = sum((v.ects() for v in ue_validation_by_niveau.values()))
|
|
|
|
|
|
|
|
logo = find_logo(logoname="header", dept_id=g.scodoc_dept_id)
|
|
|
|
|
|
|
|
return render_template(
|
|
|
|
"but/bulletin_court_page.j2",
|
|
|
|
bul=bul,
|
|
|
|
bulletins_sem=bulletins_sem,
|
|
|
|
cursus=cursus,
|
|
|
|
datetime=datetime,
|
|
|
|
decision_ues=decision_ues,
|
|
|
|
ects_total=ects_total,
|
|
|
|
etud=etud,
|
|
|
|
formsemestre=formsemestre,
|
|
|
|
logo=logo,
|
|
|
|
sco=ScoData(formsemestre=formsemestre, etud=etud),
|
|
|
|
time=time,
|
2023-08-03 13:48:22 +02:00
|
|
|
title=f"Bul. {etud.nom_disp()} BUT (court)",
|
2023-08-02 00:13:31 +02:00
|
|
|
ue_validation_by_niveau=ue_validation_by_niveau,
|
|
|
|
)
|