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-26 17:12:30 +02:00
|
|
|
|
from app.api.auth import token_permission_required
|
|
|
|
|
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
|
|
|
|
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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-26 17:12:30 +02:00
|
|
|
|
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
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:
|
2022-04-26 17:12:30 +02:00
|
|
|
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
2022-04-25 15:25:45 +02:00
|
|
|
|
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-26 17:12:30 +02:00
|
|
|
|
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])
|
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
|
|
|
|
|
"""
|
2022-04-26 17:12:30 +02:00
|
|
|
|
# Fonction utilisée : app.scodoc.sco_bulletins.get_formsemestre_bulletin_etud_json()
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
|
formsemestre = models.FormSemestre.query.filter_by(
|
|
|
|
|
id=formsemestre_id
|
|
|
|
|
).first_or_404()
|
|
|
|
|
|
|
|
|
|
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
|
|
|
|
|
|
|
|
|
app.set_sco_dept(dept.acronym)
|
|
|
|
|
|
|
|
|
|
etuds = formsemestre.etuds
|
|
|
|
|
|
|
|
|
|
data = []
|
|
|
|
|
for etu in etuds:
|
|
|
|
|
bul_etu = get_formsemestre_bulletin_etud_json(formsemestre, etu)
|
|
|
|
|
data.append(bul_etu.json)
|
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()
|
|
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
|
formsemestre = models.FormSemestre.query.filter_by(
|
|
|
|
|
id=formsemestre_id
|
|
|
|
|
).first_or_404()
|
|
|
|
|
|
|
|
|
|
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
|
|
|
|
|
|
|
|
|
app.set_sco_dept(dept.acronym)
|
|
|
|
|
|
|
|
|
|
data = formsemestre_pvjury(formsemestre_id)
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# # Utilisation de la fonction formsemestre_pvjury
|
|
|
|
|
# data = formsemestre_pvjury(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
|
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
|
return jsonify(data)
|