API: formsemestre/apo/

This commit is contained in:
Emmanuel Viennet 2022-04-27 09:24:20 +02:00
parent f0ce0b574e
commit 55b786e655
3 changed files with 17 additions and 25 deletions

View File

@ -344,8 +344,6 @@ def etudiant_bulletin_semestre(
}
}
"""
# Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud()
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()

View File

@ -188,29 +188,6 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
return jsonify(data)
@bp.route("/formations/apo/<string:etape_apo>", methods=["GET"])
@token_permission_required(Permission.APIView)
def formsemestre_apo(etape_apo: int):
"""
Retourne les informations sur les formsemestres
etape_apo : l'id d'une étape apogée
"""
# Récupération des formsemestres
apos = models.FormSemestreEtape.query.filter_by(etape_apo=etape_apo)
data = []
# Filtre les formsemestres correspondant + mise en forme des données
for apo in apos:
formsem = models.FormSemestre.query.filter_by(
id=apo["formsemestre_id"]
).first_or_404()
data.append(formsem.to_dict())
return jsonify(data)
# return error_response(501, message="Not implemented")
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
@token_permission_required(Permission.APIView)
def moduleimpls(moduleimpl_id: int):

View File

@ -7,6 +7,7 @@ from app.api import bp
from app.api.errors import error_response
from app.api.auth import token_permission_required
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
from app.models import FormSemestre, FormSemestreEtape
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
from app.scodoc.sco_permissions import Permission
@ -60,6 +61,22 @@ def formsemestre(formsemestre_id: int):
return jsonify(data)
@bp.route("/formsemestre/apo/<string:etape_apo>", methods=["GET"])
@token_permission_required(Permission.APIView)
def formsemestre_apo(etape_apo: str):
"""
Retourne les informations sur les formsemestres
etape_apo : l'id d'une étape apogée
"""
formsemestres = FormSemestre.query.filter(
FormSemestreEtape.etape_apo == etape_apo,
FormSemestreEtape.formsemestre_id == FormSemestre.id,
)
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
methods=["GET"],