From d06b11eb4c56fb7038bdef55cb5cb50906252a4e Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Thu, 5 May 2022 16:33:29 +0200 Subject: [PATCH] =?UTF-8?q?commencement=20du=20choix=20de=20format=20de=20?= =?UTF-8?q?retour=20pour=20le=20bulletin=20d'un=20=C3=A9tudiant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/etudiants.py | 55 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 042c72b4..9db4b7e3 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -11,6 +11,8 @@ from app.api.tools import get_etu_from_etudid_or_nip_or_ine from app.models import FormSemestreInscription, FormSemestre, Identite from app.scodoc import sco_bulletins from app.scodoc import sco_groups +from app.scodoc.sco_bulletins import do_formsemestre_bulletinetud +from app.scodoc.sco_bulletins_pdf import get_etud_bulletins_pdf from app.scodoc.sco_permissions import Permission @@ -168,32 +170,62 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None) @bp.route( "/etudiant/etudid//formsemestre//bulletin", methods=["GET"], - defaults={"version": "long"}, + defaults={"version": "long", "format": "json"}, ) @bp.route( "/etudiant/nip//formsemestre//bulletin", methods=["GET"], - defaults={"version": "long"}, + defaults={"version": "long", "format": "json"}, ) @bp.route( "/etudiant/ine//formsemestre//bulletin", methods=["GET"], - defaults={"version": "long"}, + defaults={"version": "long", "format": "json"}, +) +@bp.route( + "/etudiant/etudid//formsemestre//bulletin/pdf", + methods=["GET"], + defaults={"version": "long", "format": "pdf"}, +) +@bp.route( + "/etudiant/nip//formsemestre//bulletin/pdf", + methods=["GET"], + defaults={"version": "long", "format": "pdf"}, +) +@bp.route( + "/etudiant/ine//formsemestre//bulletin/pdf", + methods=["GET"], + defaults={"version": "long", "format": "pdf"}, ) @bp.route( "/etudiant/etudid//formsemestre//bulletin/short", methods=["GET"], - defaults={"version": "short"}, + defaults={"version": "short", "format": "json"}, ) @bp.route( "/etudiant/nip//formsemestre//bulletin/short", methods=["GET"], - defaults={"version": "short"}, + defaults={"version": "short", "format": "json"}, ) @bp.route( "/etudiant/ine//formsemestre//bulletin/short", methods=["GET"], - defaults={"version": "short"}, + defaults={"version": "short", "format": "json"}, +) +@bp.route( + "/etudiant/etudid//formsemestre//bulletin/short/pdf", + methods=["GET"], + defaults={"version": "short", "format": "pdf"}, +) +@bp.route( + "/etudiant/nip//formsemestre//bulletin/short/pdf", + methods=["GET"], + defaults={"version": "short", "format": "pdf"}, +) +@bp.route( + "/etudiant/ine//formsemestre//bulletin/short/pdf", + methods=["GET"], + defaults={"version": "short", "format": "pdf"}, ) @token_auth.login_required @token_permission_required(Permission.APIView) @@ -203,6 +235,7 @@ def etudiant_bulletin_semestre( nip: int = None, ine: int = None, version="long", + format="json", ): """ Retourne le bulletin d'un étudiant en fonction de son id et d'un semestre donné @@ -397,8 +430,14 @@ def etudiant_bulletin_semestre( message="La requête ne peut être traitée en l’état actuel.\n " "Veuillez vérifier que l'id de l'étudiant (etudid, nip, ine) est valide", ) - - return sco_bulletins.get_formsemestre_bulletin_etud_json(formsemestre, etu, version) + if format == "json": + return sco_bulletins.get_formsemestre_bulletin_etud_json( + formsemestre, etu, version + ) + else: + etudid = etu.id + print(etudid) + return do_formsemestre_bulletinetud(formsemestre, etudid, version, format) @bp.route(