Compare commits

...

3 Commits

3 changed files with 49 additions and 9 deletions

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(

View File

@ -314,7 +314,7 @@ def formsemestre_bulletinetud(
)
if format == "json":
return sco_bulletins.get_formsemestre_bulletin_etud_json(
formsemestre, etud, version=version
formsemestre, etud, version=version, force_publishing=force_publishing
)
if formsemestre.formation.is_apc() and format == "html":
return render_template(

1
tests/api/__init__.py Normal file
View File

@ -0,0 +1 @@
# API tests