2022-03-02 16:45:47 +01:00
|
|
|
|
########################################## Formsemestres ##############################################################
|
|
|
|
|
from flask import jsonify
|
|
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
|
import app
|
2022-03-02 16:45:47 +01:00
|
|
|
|
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-04-22 16:22:10 +02:00
|
|
|
|
from app.api.tools import get_etu_from_request
|
2022-04-20 15:50:02 +02:00
|
|
|
|
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
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
|
2022-04-25 15:25:45 +02:00
|
|
|
|
from app.scodoc.sco_recapcomplet import (
|
|
|
|
|
formsemestre_recapcomplet,
|
|
|
|
|
gen_formsemestre_recapcomplet_json,
|
|
|
|
|
)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@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
|
2022-04-22 16:22:10 +02:00
|
|
|
|
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
# Mise en forme des données
|
2022-04-22 16:22:10 +02:00
|
|
|
|
data = formsemetre.to_dict()
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
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_permission_required(Permission.APIView)
|
2022-04-25 15:25:45 +02:00
|
|
|
|
def etudiant_bulletin(
|
|
|
|
|
formsemestre_id,
|
|
|
|
|
dept,
|
|
|
|
|
format="json",
|
|
|
|
|
etudid: int = None,
|
|
|
|
|
nip: int = None,
|
|
|
|
|
ine: int = None,
|
|
|
|
|
): # *args, size
|
2022-03-02 16:45:47 +01:00
|
|
|
|
"""
|
|
|
|
|
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()
|
|
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
|
# make_json_formsemestre_bulletinetud
|
|
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
|
try:
|
|
|
|
|
app.set_sco_dept(dept)
|
|
|
|
|
except:
|
|
|
|
|
return error_response(
|
|
|
|
|
409,
|
|
|
|
|
message="La requête ne peut être traitée en l’état actuel.\n "
|
|
|
|
|
"Veilliez vérifier que le nom de département est valide",
|
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
|
if etudid is None:
|
2022-04-22 16:22:10 +02:00
|
|
|
|
# Récupération de l'étudiant
|
2022-04-25 15:25:45 +02:00
|
|
|
|
try:
|
|
|
|
|
etu = get_etu_from_request(etudid, nip, ine)
|
|
|
|
|
etudid = etu.etudid
|
|
|
|
|
except AttributeError:
|
|
|
|
|
return error_response(
|
|
|
|
|
409,
|
|
|
|
|
message="La requête ne peut être traitée en l’état actuel.\n "
|
|
|
|
|
"Veilliez vérifier que l'id de l'étudiant (etudid, nip, ine) est valide",
|
|
|
|
|
)
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
2022-04-22 16:22:10 +02:00
|
|
|
|
data = make_json_formsemestre_bulletinetud(formsemestre_id, etudid)
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
2022-04-22 16:22:10 +02:00
|
|
|
|
return data
|
2022-04-20 15:50:02 +02:00
|
|
|
|
|
|
|
|
|
# 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)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
|
@bp.route(
|
|
|
|
|
"/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"]
|
|
|
|
|
) # XXX TODO à revoir
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@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()
|
2022-04-25 15:25:45 +02:00
|
|
|
|
# gen_formsemestre_recapcomplet_json ??
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Utilisation de la fonction formsemestre_recapcomplet
|
2022-04-25 15:25:45 +02:00
|
|
|
|
# data = formsemestre_recapcomplet(formsemestre_id)
|
|
|
|
|
data = gen_formsemestre_recapcomplet_json(formsemestre_id)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
return error_response(
|
|
|
|
|
409,
|
|
|
|
|
message="La requête ne peut être traitée en l’état actuel. \n"
|
|
|
|
|
"Veillez vérifier la conformité du 'formation_id'",
|
|
|
|
|
)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/formsemestre/<int:formsemestre_id>/jury", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
|
@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)
|
2022-04-25 15:25:45 +02:00
|
|
|
|
except AttributeError:
|
|
|
|
|
return error_response(
|
|
|
|
|
409,
|
|
|
|
|
message="La requête ne peut être traitée en l’état actuel. \n"
|
|
|
|
|
"Veillez vérifier la conformité du 'formation_id'",
|
|
|
|
|
)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
|
return jsonify(data)
|