forked from ScoDoc/ScoDoc
ébauche retour de bulletin pdf d'un formsemestre d'un etudiant
This commit is contained in:
parent
950b8b06d4
commit
76bb83c55a
@ -18,6 +18,7 @@ from app.api.tools import get_last_instance_etud_from_etudid_or_nip_or_ine
|
||||
from app.models import Departement, FormSemestreInscription, FormSemestre, Identite
|
||||
from app.scodoc import sco_bulletins
|
||||
from app.scodoc import sco_groups
|
||||
from app.scodoc.sco_bulletins_pdf import get_etud_bulletins_pdf, get_bulletin_etud_formsemestre
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
||||
|
||||
@ -230,11 +231,11 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
||||
defaults={"version": "long", "pdf": False},
|
||||
)
|
||||
# Version PDF non fonctionnelle
|
||||
# @bp.route(
|
||||
# "/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
|
||||
# methods=["GET"],
|
||||
# defaults={"version": "long", "pdf": True},
|
||||
# )
|
||||
@bp.route(
|
||||
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
|
||||
methods=["GET"],
|
||||
defaults={"version": "long", "pdf": True},
|
||||
)
|
||||
# @bp.route(
|
||||
# "/etudiant/nip/<string:nip>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
|
||||
# methods=["GET"],
|
||||
@ -461,6 +462,11 @@ def etudiant_bulletin_semestre( # XXX TODO Ajouter la possibilité de retourner
|
||||
)
|
||||
|
||||
app.set_sco_dept(dept.acronym)
|
||||
|
||||
if pdf:
|
||||
return get_bulletin_etud_formsemestre(etudid, formsemestre_id, version)
|
||||
|
||||
|
||||
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
||||
formsemestre, etud, version
|
||||
)
|
||||
|
@ -271,6 +271,59 @@ def get_etud_bulletins_pdf(etudid, version="selectedevals"):
|
||||
return pdfdoc, filename
|
||||
|
||||
|
||||
def get_bulletin_etud_formsemestre_pdf(etudid: int, formsemestre_id: int, version: str = "long"):
|
||||
"""
|
||||
Retourne le bulletin au format pdf d'un semestre d'un etudiant
|
||||
|
||||
etudid : l'id de l'étudiant
|
||||
formsemestre_id : l'id d'un semestre
|
||||
"""
|
||||
from app.scodoc import sco_bulletins
|
||||
|
||||
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
||||
fragments = []
|
||||
bookmarks = {}
|
||||
filigrannes = {}
|
||||
|
||||
formsemestre = FormSemestre.query.get(formsemestre_id)
|
||||
frag, filigranne = sco_bulletins.do_formsemestre_bulletinetud(
|
||||
formsemestre,
|
||||
etudid,
|
||||
format="pdfpart",
|
||||
version=version,
|
||||
)
|
||||
# fragments += frag
|
||||
# filigrannes[i] = filigranne
|
||||
# bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015
|
||||
|
||||
infos = {"DeptName": sco_preferences.get_preference("DeptName")}
|
||||
if request:
|
||||
server_name = request.url_root
|
||||
else:
|
||||
server_name = ""
|
||||
try:
|
||||
sco_pdf.PDFLOCK.acquire()
|
||||
pdfdoc = assemble_bulletins_pdf(
|
||||
None,
|
||||
fragments,
|
||||
etud["nomprenom"],
|
||||
infos,
|
||||
bookmarks,
|
||||
filigranne=filigrannes,
|
||||
server_name=server_name,
|
||||
)
|
||||
finally:
|
||||
sco_pdf.PDFLOCK.release()
|
||||
#
|
||||
filename = "bul-%s" % (etud["nomprenom"])
|
||||
filename = (
|
||||
scu.unescape_html(filename).replace(" ", "_").replace("&", "").replace(".", "")
|
||||
+ ".pdf"
|
||||
)
|
||||
|
||||
return pdfdoc, filename
|
||||
|
||||
|
||||
def get_filigranne(etud_etat: str, prefs, decision_sem=None) -> str:
|
||||
"""Texte à placer en "filigranne" sur le bulletin pdf"""
|
||||
if etud_etat == scu.DEMISSION:
|
||||
|
Loading…
Reference in New Issue
Block a user