2022-03-02 16:45:47 +01:00
|
|
|
|
########################################## Formsemestres ##############################################################
|
|
|
|
|
from flask import jsonify
|
|
|
|
|
|
|
|
|
|
from app import models
|
|
|
|
|
from app.api import bp
|
|
|
|
|
from app.api.errors import error_response
|
2022-04-14 14:56:36 +02:00
|
|
|
|
from app.api.auth import token_auth, token_permission_required
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
2022-03-04 17:16:08 +01:00
|
|
|
|
from app.scodoc.sco_permissions import Permission
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
|
|
|
|
from app.scodoc.sco_recapcomplet import formsemestre_recapcomplet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@token_auth.login_required
|
|
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def formsemestre(formsemestre_id: int):
|
|
|
|
|
"""
|
|
|
|
|
Retourne l'information sur le formsemestre correspondant au formsemestre_id
|
|
|
|
|
|
|
|
|
|
formsemestre_id : l'id d'un formsemestre
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
# Récupération de tous les formsemestres
|
|
|
|
|
list_formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id)
|
|
|
|
|
|
|
|
|
|
# Mise en forme des données
|
|
|
|
|
data = list_formsemetre[0].to_dict()
|
|
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route(
|
|
|
|
|
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
|
|
|
|
|
methods=["GET"],
|
|
|
|
|
)
|
|
|
|
|
@bp.route(
|
|
|
|
|
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
|
|
|
|
|
methods=["GET"],
|
|
|
|
|
)
|
|
|
|
|
@bp.route(
|
|
|
|
|
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
|
|
|
|
|
methods=["GET"],
|
|
|
|
|
)
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@token_auth.login_required
|
|
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def etudiant_bulletin(formsemestre_id, dept, etudid, format="json", *args, size):
|
|
|
|
|
"""
|
|
|
|
|
Retourne le bulletin de note d'un étudiant
|
|
|
|
|
|
|
|
|
|
formsemestre_id : l'id d'un formsemestre
|
|
|
|
|
etudid : l'etudid d'un étudiant
|
|
|
|
|
nip : le code nip d'un étudiant
|
|
|
|
|
ine : le code ine d'un étudiant
|
|
|
|
|
"""
|
|
|
|
|
# Fonction utilisée : app.scodoc.sco_bulletins.formsemestre_billetinetud_dict()
|
|
|
|
|
|
|
|
|
|
data = []
|
|
|
|
|
if args[0] == "short":
|
|
|
|
|
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid, version=args[0])
|
|
|
|
|
elif args[0] == "selectevals":
|
|
|
|
|
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid, version=args[0])
|
|
|
|
|
elif args[0] == "long":
|
|
|
|
|
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid)
|
|
|
|
|
else:
|
|
|
|
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
|
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@token_auth.login_required
|
|
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def bulletins(formsemestre_id: int):
|
|
|
|
|
"""
|
|
|
|
|
Retourne les bulletins d'un formsemestre donné
|
|
|
|
|
|
|
|
|
|
formsemestre_id : l'id d'un formesemestre
|
|
|
|
|
"""
|
|
|
|
|
# Fonction utilisée : app.scodoc.sco_recapcomplet.formsemestre_recapcomplet()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Utilisation de la fonction formsemestre_recapcomplet
|
|
|
|
|
data = formsemestre_recapcomplet(formsemestre_id)
|
|
|
|
|
except ValueError:
|
|
|
|
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
|
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formsemestre/<int:formsemestre_id>/jury", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@token_auth.login_required
|
|
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def jury(formsemestre_id: int):
|
|
|
|
|
"""
|
|
|
|
|
Retourne le récapitulatif des décisions jury
|
|
|
|
|
|
|
|
|
|
formsemestre_id : l'id d'un formsemestre
|
|
|
|
|
"""
|
|
|
|
|
# Fonction utilisée : app.scodoc.sco_pvjury.formsemestre_pvjury()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Utilisation de la fonction formsemestre_pvjury
|
|
|
|
|
data = formsemestre_pvjury(formsemestre_id)
|
|
|
|
|
except ValueError:
|
|
|
|
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
|
|
|
|
|
|
|
|
|
return jsonify(data)
|