From f4aa04bb7609d4531ecef9704f6ac8f69c26e08e Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Mon, 23 May 2022 15:46:36 +0200 Subject: [PATCH] =?UTF-8?q?correction=20bulletin=20etudiant=20pdf=20+=20su?= =?UTF-8?q?ppression=20de=20la=20fonction=20pr=C3=A9c=C3=A9dement=20cr?= =?UTF-8?q?=C3=A9er=20qui=20=C3=A9tait=20inutil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/etudiants.py | 11 ++++--- app/scodoc/sco_bulletins_pdf.py | 53 --------------------------------- 2 files changed, 7 insertions(+), 57 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 6bf1cc3f..1d33b04b 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -8,7 +8,7 @@ API : accès aux étudiants """ -from flask import jsonify +from flask import jsonify, make_response import app from app.api import bp @@ -18,7 +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_bulletin_etud_formsemestre_pdf +from app.scodoc.sco_bulletins import do_formsemestre_bulletinetud from app.scodoc.sco_permissions import Permission @@ -464,8 +464,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_pdf(etudid, formsemestre_id, version) - + response = make_response( + do_formsemestre_bulletinetud(formsemestre, etudid, version, "pdf") + ) + response.headers["Content-Type"] = "application/json" + return response return sco_bulletins.get_formsemestre_bulletin_etud_json( formsemestre, etud, version diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index 7fc8f983..e0ac4e14 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -271,59 +271,6 @@ 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) - fragments, filigranne = sco_bulletins.do_formsemestre_bulletinetud( - formsemestre, - etudid, - format="pdfpart", - version=version, - ) - # fragments.append(frag) - filigrannes[0] = 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( - formsemestre_id, - 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: