commencement du choix de format de retour pour le bulletin d'un étudiant

This commit is contained in:
leonard_montalbano 2022-05-05 16:33:29 +02:00
parent 2cc1ab13d3
commit d06b11eb4c

View File

@ -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/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "format": "json"},
)
@bp.route(
"/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "format": "json"},
)
@bp.route(
"/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "format": "json"},
)
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
methods=["GET"],
defaults={"version": "long", "format": "pdf"},
)
@bp.route(
"/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
methods=["GET"],
defaults={"version": "long", "format": "pdf"},
)
@bp.route(
"/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
methods=["GET"],
defaults={"version": "long", "format": "pdf"},
)
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "format": "json"},
)
@bp.route(
"/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "format": "json"},
)
@bp.route(
"/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "format": "json"},
)
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/short/pdf",
methods=["GET"],
defaults={"version": "short", "format": "pdf"},
)
@bp.route(
"/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin/short/pdf",
methods=["GET"],
defaults={"version": "short", "format": "pdf"},
)
@bp.route(
"/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/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(