forked from ScoDoc/ScoDoc
Prise en compte des remarques du 26/04/2022 sur différents fichiers de /api
This commit is contained in:
parent
ce2b7334c6
commit
46d99a5735
@ -33,4 +33,3 @@ from app.api import evaluations
|
|||||||
from app.api import jury
|
from app.api import jury
|
||||||
from app.api import absences
|
from app.api import absences
|
||||||
from app.api import logos
|
from app.api import logos
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from app import models
|
|||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
from app.api.auth import token_permission_required
|
from app.api.auth import token_permission_required
|
||||||
from app.api.tools import get_etu_from_request
|
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||||
from app.scodoc.sco_abs import (
|
from app.scodoc.sco_abs import (
|
||||||
add_absence,
|
add_absence,
|
||||||
add_justif,
|
add_justif,
|
||||||
@ -34,7 +34,7 @@ def absences(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
@ -44,7 +44,7 @@ def absences(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Récupération des absences de l'étudiant
|
# Récupération des absences de l'étudiant
|
||||||
abs = models.Absence.query.filter_by(etudid=etudid).all()
|
abs = models.Absence.query.filter_by(etudid=etudid)
|
||||||
|
|
||||||
# Si l'étudiant a au minimum une absence
|
# Si l'étudiant a au minimum une absence
|
||||||
if len(abs) > 0:
|
if len(abs) > 0:
|
||||||
@ -71,7 +71,7 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
@ -81,7 +81,7 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Récupération des absences justifiées de l'étudiant
|
# Récupération des absences justifiées de l'étudiant
|
||||||
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True).all()
|
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True)
|
||||||
|
|
||||||
# Si l'étudiant a au minimum une absence justifiées
|
# Si l'étudiant a au minimum une absence justifiées
|
||||||
if len(abs) > 0:
|
if len(abs) > 0:
|
||||||
@ -95,75 +95,6 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
### Inutil en définitif ###
|
|
||||||
@bp.route(
|
|
||||||
"/absences/abs_signale?etudid=<int:etudid>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
|
||||||
"&description=<string:description>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@bp.route(
|
|
||||||
"/absences/abs_signale?nip=<int:nip>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
|
||||||
"&description=<string:description>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@bp.route(
|
|
||||||
"/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
|
||||||
"&description=<string:description>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@bp.route(
|
|
||||||
"/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
|
||||||
"&description=<string:description>&moduleimpl_id=<int:moduleimpl_id>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@token_permission_required(Permission.APIAbsChange)
|
|
||||||
def abs_signale(
|
|
||||||
date: datetime,
|
|
||||||
matin: bool,
|
|
||||||
justif: bool,
|
|
||||||
etudid: int = None,
|
|
||||||
nip: int = None,
|
|
||||||
ine: int = None, ### Inutil en définitif
|
|
||||||
description: str = None,
|
|
||||||
moduleimpl_id: int = None,
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Permet d'ajouter une absence en base
|
|
||||||
|
|
||||||
date : la date de l'absence
|
|
||||||
matin : True ou False
|
|
||||||
justif : True ou False
|
|
||||||
etudid : l'etudid d'un étudiant
|
|
||||||
nip: le code nip d'un étudiant
|
|
||||||
ine : le code ine d'un étudiant
|
|
||||||
description : description possible à ajouter sur l'absence
|
|
||||||
moduleimpl_id : l'id d'un moduleimpl
|
|
||||||
"""
|
|
||||||
# Fonctions utilisées : app.scodoc.sco_abs.add_absence() et app.scodoc.sco_abs.add_justif()
|
|
||||||
|
|
||||||
if etudid is None:
|
|
||||||
# Récupération de l'étudiant
|
|
||||||
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",
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
# Utilisation de la fonction add_absence
|
|
||||||
add_absence(etudid, date, matin, justif, description, moduleimpl_id)
|
|
||||||
if justif == True:
|
|
||||||
# Utilisation de la fonction add_justif
|
|
||||||
add_justif(etudid, date, matin, description)
|
|
||||||
except ValueError:
|
|
||||||
return error_response(
|
|
||||||
409, message="La requête ne peut être traitée en l’état actuel"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
"/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>",
|
"/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>",
|
||||||
methods=["POST"],
|
methods=["POST"],
|
||||||
@ -194,7 +125,7 @@ def abs_annule(
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
@ -246,7 +177,7 @@ def abs_annule_justif(
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
|
@ -67,7 +67,9 @@ def liste_etudiants(dept: str, formsemestre_id=None):
|
|||||||
# Si le formsemestre_id a été renseigné
|
# Si le formsemestre_id a été renseigné
|
||||||
if formsemestre_id is not None:
|
if formsemestre_id is not None:
|
||||||
# Récupération du formsemestre
|
# Récupération du formsemestre
|
||||||
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
formsemestre = models.FormSemestre.query.filter_by(
|
||||||
|
id=formsemestre_id
|
||||||
|
).first_or_404()
|
||||||
# Récupération du département
|
# Récupération du département
|
||||||
departement = formsemestre.departement
|
departement = formsemestre.departement
|
||||||
|
|
||||||
@ -180,7 +182,9 @@ def semestre_index(dept: str, formsemestre_id: int):
|
|||||||
|
|
||||||
app.set_sco_dept(dept)
|
app.set_sco_dept(dept)
|
||||||
|
|
||||||
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
formsemestre = models.FormSemestre.query.filter_by(
|
||||||
|
id=formsemestre_id
|
||||||
|
).first_or_404()
|
||||||
|
|
||||||
ues = formsemestre.query_ues()
|
ues = formsemestre.query_ues()
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from app import models
|
|||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
from app.api.auth import token_permission_required
|
from app.api.auth import token_permission_required
|
||||||
from app.api.tools import get_etu_from_request
|
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||||
from app.models import FormSemestreInscription, FormSemestre, Identite
|
from app.models import FormSemestreInscription, FormSemestre, Identite
|
||||||
from app.scodoc import sco_bulletins
|
from app.scodoc import sco_bulletins
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
@ -21,6 +21,7 @@ def etudiants_courant():
|
|||||||
Retourne la liste des étudiants courant
|
Retourne la liste des étudiants courant
|
||||||
|
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
|
{
|
||||||
{
|
{
|
||||||
"civilite": "X",
|
"civilite": "X",
|
||||||
"code_ine": null,
|
"code_ine": null,
|
||||||
@ -44,6 +45,7 @@ def etudiants_courant():
|
|||||||
"prenom": "ANNE"
|
"prenom": "ANNE"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
# Récupération de tous les étudiants
|
# Récupération de tous les étudiants
|
||||||
etuds = Identite.query.filter(
|
etuds = Identite.query.filter(
|
||||||
@ -84,7 +86,7 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = etu.to_dict_bul(include_urls=False)
|
data = etu.to_dict_bul(include_urls=False)
|
||||||
@ -98,7 +100,7 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des semestres qu'un étudiant a suivi, triés par ordre chronologique.
|
Retourne la liste des semestres qu'un étudiant a suivis, triés par ordre chronologique.
|
||||||
|
|
||||||
etudid : l'etudid d'un étudiant
|
etudid : l'etudid d'un étudiant
|
||||||
nip : le code nip d'un étudiant
|
nip : le code nip d'un étudiant
|
||||||
@ -139,7 +141,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
etud = get_etu_from_request(etudid, nip, ine)
|
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
|
|
||||||
formsemestres = models.FormSemestre.query.filter(
|
formsemestres = models.FormSemestre.query.filter(
|
||||||
models.FormSemestreInscription.etudid == etud.id,
|
models.FormSemestreInscription.etudid == etud.id,
|
||||||
@ -185,7 +187,7 @@ def etudiant_bulletin_semestre(
|
|||||||
|
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
409,
|
409,
|
||||||
@ -247,7 +249,7 @@ def etudiant_groups(
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
|
@ -5,15 +5,12 @@ import app
|
|||||||
from app import models
|
from app import models
|
||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
from app.api.auth import token_auth, token_permission_required
|
from app.api.auth import token_permission_required
|
||||||
from app.api.tools import get_etu_from_request
|
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||||
|
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_bulletins_json import make_json_formsemestre_bulletinetud
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
||||||
from app.scodoc.sco_recapcomplet import (
|
|
||||||
formsemestre_recapcomplet,
|
|
||||||
gen_formsemestre_recapcomplet_json,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
||||||
@ -26,7 +23,7 @@ def formsemestre(formsemestre_id: int):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
# Récupération de tous les formsemestres
|
# Récupération de tous les formsemestres
|
||||||
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = formsemetre.to_dict()
|
data = formsemetre.to_dict()
|
||||||
@ -78,7 +75,7 @@ def etudiant_bulletin(
|
|||||||
if etudid is None:
|
if etudid is None:
|
||||||
# Récupération de l'étudiant
|
# Récupération de l'étudiant
|
||||||
try:
|
try:
|
||||||
etu = get_etu_from_request(etudid, nip, ine)
|
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||||
etudid = etu.etudid
|
etudid = etu.etudid
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return error_response(
|
return error_response(
|
||||||
@ -103,9 +100,7 @@ def etudiant_bulletin(
|
|||||||
# return jsonify(data)
|
# return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])
|
||||||
"/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"]
|
|
||||||
) # XXX TODO à revoir
|
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def bulletins(formsemestre_id: int):
|
def bulletins(formsemestre_id: int):
|
||||||
"""
|
"""
|
||||||
@ -113,19 +108,22 @@ def bulletins(formsemestre_id: int):
|
|||||||
|
|
||||||
formsemestre_id : l'id d'un formesemestre
|
formsemestre_id : l'id d'un formesemestre
|
||||||
"""
|
"""
|
||||||
# Fonction utilisée : app.scodoc.sco_recapcomplet.formsemestre_recapcomplet()
|
# Fonction utilisée : app.scodoc.sco_bulletins.get_formsemestre_bulletin_etud_json()
|
||||||
# gen_formsemestre_recapcomplet_json ??
|
|
||||||
|
|
||||||
try:
|
formsemestre = models.FormSemestre.query.filter_by(
|
||||||
# Utilisation de la fonction formsemestre_recapcomplet
|
id=formsemestre_id
|
||||||
# data = formsemestre_recapcomplet(formsemestre_id)
|
).first_or_404()
|
||||||
data = gen_formsemestre_recapcomplet_json(formsemestre_id)
|
|
||||||
except AttributeError:
|
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
||||||
return error_response(
|
|
||||||
409,
|
app.set_sco_dept(dept.acronym)
|
||||||
message="La requête ne peut être traitée en l’état actuel. \n"
|
|
||||||
"Veillez vérifier la conformité du 'formation_id'",
|
etuds = formsemestre.etuds
|
||||||
)
|
|
||||||
|
data = []
|
||||||
|
for etu in etuds:
|
||||||
|
bul_etu = get_formsemestre_bulletin_etud_json(formsemestre, etu)
|
||||||
|
data.append(bul_etu.json)
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
@ -140,14 +138,24 @@ def jury(formsemestre_id: int):
|
|||||||
"""
|
"""
|
||||||
# Fonction utilisée : app.scodoc.sco_pvjury.formsemestre_pvjury()
|
# Fonction utilisée : app.scodoc.sco_pvjury.formsemestre_pvjury()
|
||||||
|
|
||||||
try:
|
formsemestre = models.FormSemestre.query.filter_by(
|
||||||
# Utilisation de la fonction formsemestre_pvjury
|
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)
|
data = formsemestre_pvjury(formsemestre_id)
|
||||||
except AttributeError:
|
|
||||||
return error_response(
|
# try:
|
||||||
409,
|
# # Utilisation de la fonction formsemestre_pvjury
|
||||||
message="La requête ne peut être traitée en l’état actuel. \n"
|
# data = formsemestre_pvjury(formsemestre_id)
|
||||||
"Veillez vérifier la conformité du 'formation_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'",
|
||||||
|
# )
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
@ -19,7 +19,7 @@ def partition(formsemestre_id: int):
|
|||||||
formsemestre_id : l'id d'un formsemestre
|
formsemestre_id : l'id d'un formsemestre
|
||||||
"""
|
"""
|
||||||
# Récupération de toutes les partitions
|
# Récupération de toutes les partitions
|
||||||
partitions = models.Partition.query.filter_by(id=formsemestre_id).all()
|
partitions = models.Partition.query.filter_by(id=formsemestre_id)
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = [d.to_dict() for d in partitions]
|
data = [d.to_dict() for d in partitions]
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
# return jsonify(data)
|
# return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# @bp.route(
|
# @bp.route(
|
||||||
# "/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<float:note>",
|
# "/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<float:note>",
|
||||||
# methods=["POST"],
|
# methods=["POST"],
|
||||||
@ -70,3 +68,72 @@
|
|||||||
# # Qu'est ce qu'un user ???
|
# # Qu'est ce qu'un user ???
|
||||||
# # notes_add()
|
# # notes_add()
|
||||||
# return error_response(501, message="Not implemented")
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
# ### Inutil en définitif ###
|
||||||
|
# @bp.route(
|
||||||
|
# "/absences/abs_signale?etudid=<int:etudid>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
# "&description=<string:description>",
|
||||||
|
# methods=["POST"],
|
||||||
|
# )
|
||||||
|
# @bp.route(
|
||||||
|
# "/absences/abs_signale?nip=<int:nip>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
# "&description=<string:description>",
|
||||||
|
# methods=["POST"],
|
||||||
|
# )
|
||||||
|
# @bp.route(
|
||||||
|
# "/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
# "&description=<string:description>",
|
||||||
|
# methods=["POST"],
|
||||||
|
# )
|
||||||
|
# @bp.route(
|
||||||
|
# "/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
# "&description=<string:description>&moduleimpl_id=<int:moduleimpl_id>",
|
||||||
|
# methods=["POST"],
|
||||||
|
# )
|
||||||
|
# @token_permission_required(Permission.APIAbsChange)
|
||||||
|
# def abs_signale(
|
||||||
|
# date: datetime,
|
||||||
|
# matin: bool,
|
||||||
|
# justif: bool,
|
||||||
|
# etudid: int = None,
|
||||||
|
# nip: int = None,
|
||||||
|
# ine: int = None, ### Inutil en définitif
|
||||||
|
# description: str = None,
|
||||||
|
# moduleimpl_id: int = None,
|
||||||
|
# ):
|
||||||
|
# """
|
||||||
|
# Permet d'ajouter une absence en base
|
||||||
|
#
|
||||||
|
# date : la date de l'absence
|
||||||
|
# matin : True ou False
|
||||||
|
# justif : True ou False
|
||||||
|
# etudid : l'etudid d'un étudiant
|
||||||
|
# nip: le code nip d'un étudiant
|
||||||
|
# ine : le code ine d'un étudiant
|
||||||
|
# description : description possible à ajouter sur l'absence
|
||||||
|
# moduleimpl_id : l'id d'un moduleimpl
|
||||||
|
# """
|
||||||
|
# # Fonctions utilisées : app.scodoc.sco_abs.add_absence() et app.scodoc.sco_abs.add_justif()
|
||||||
|
#
|
||||||
|
# if etudid is None:
|
||||||
|
# # Récupération de l'étudiant
|
||||||
|
# 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",
|
||||||
|
# )
|
||||||
|
# try:
|
||||||
|
# # Utilisation de la fonction add_absence
|
||||||
|
# add_absence(etudid, date, matin, justif, description, moduleimpl_id)
|
||||||
|
# if justif == True:
|
||||||
|
# # Utilisation de la fonction add_justif
|
||||||
|
# add_justif(etudid, date, matin, description)
|
||||||
|
# except ValueError:
|
||||||
|
# return error_response(
|
||||||
|
# 409, message="La requête ne peut être traitée en l’état actuel"
|
||||||
|
# )
|
||||||
|
@ -50,19 +50,26 @@ from app.api.errors import error_response
|
|||||||
from app import models
|
from app import models
|
||||||
from app.models import FormSemestre, FormSemestreInscription, Identite
|
from app.models import FormSemestre, FormSemestreInscription, Identite
|
||||||
from app.models import ApcReferentielCompetences
|
from app.models import ApcReferentielCompetences
|
||||||
from app.scodoc.sco_abs import annule_absence, annule_justif, add_absence, add_justif, list_abs_date
|
from app.scodoc.sco_abs import (
|
||||||
|
annule_absence,
|
||||||
|
annule_justif,
|
||||||
|
add_absence,
|
||||||
|
add_justif,
|
||||||
|
list_abs_date,
|
||||||
|
)
|
||||||
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
||||||
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
||||||
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
|
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
|
||||||
from app.scodoc.sco_formations import formation_export
|
from app.scodoc.sco_formations import formation_export
|
||||||
from app.scodoc.sco_formsemestre_inscriptions import do_formsemestre_inscription_listinscrits
|
from app.scodoc.sco_formsemestre_inscriptions import (
|
||||||
|
do_formsemestre_inscription_listinscrits,
|
||||||
|
)
|
||||||
from app.scodoc.sco_groups import setGroups, get_etud_groups, get_group_members
|
from app.scodoc.sco_groups import setGroups, get_etud_groups, get_group_members
|
||||||
from app.scodoc.sco_logos import list_logos, find_logo, _list_dept_logos
|
from app.scodoc.sco_logos import list_logos, find_logo, _list_dept_logos
|
||||||
from app.scodoc.sco_moduleimpl import moduleimpl_list
|
from app.scodoc.sco_moduleimpl import moduleimpl_list
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ###################################################### Logos ##########################################################
|
# ###################################################### Logos ##########################################################
|
||||||
#
|
#
|
||||||
# # XXX TODO voir get_logo déjà existant dans app/views/scodoc.py
|
# # XXX TODO voir get_logo déjà existant dans app/views/scodoc.py
|
||||||
@ -143,5 +150,3 @@ from app.scodoc.sco_permissions import Permission
|
|||||||
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||||
# #
|
# #
|
||||||
# # return res
|
# # return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from app import models
|
from app import models
|
||||||
|
|
||||||
|
|
||||||
def get_etu_from_request(etudid, nip, ine):
|
def get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine):
|
||||||
"""
|
"""
|
||||||
Fonction qui retourne un etudiant en fonction de l'etudid, code nip et code ine rentré en paramètres
|
Fonction qui retourne un etudiant en fonction de l'etudid, code nip et code ine rentré en paramètres
|
||||||
|
|
||||||
|
@ -23,55 +23,55 @@ import requests
|
|||||||
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||||
|
|
||||||
|
|
||||||
# etudiants
|
# # etudiants
|
||||||
def test_etudiants():
|
# def test_etudiants():
|
||||||
|
#
|
||||||
fields = [
|
# fields = [
|
||||||
"civilite",
|
# "civilite",
|
||||||
"code_ine",
|
# "code_ine",
|
||||||
"code_nip",
|
# "code_nip",
|
||||||
"date_naissance",
|
# "date_naissance",
|
||||||
"email",
|
# "email",
|
||||||
"emailperso",
|
# "emailperso",
|
||||||
"etudid",
|
# "etudid",
|
||||||
"nom",
|
# "nom",
|
||||||
"prenom",
|
# "prenom",
|
||||||
"nomprenom",
|
# "nomprenom",
|
||||||
"lieu_naissance",
|
# "lieu_naissance",
|
||||||
"dept_naissance",
|
# "dept_naissance",
|
||||||
"nationalite",
|
# "nationalite",
|
||||||
"boursier",
|
# "boursier",
|
||||||
"id",
|
# "id",
|
||||||
"domicile",
|
# "domicile",
|
||||||
"villedomicile",
|
# "villedomicile",
|
||||||
"telephone",
|
# "telephone",
|
||||||
"fax",
|
# "fax",
|
||||||
"description",
|
# "description",
|
||||||
"codepostaldomicile",
|
# "codepostaldomicile",
|
||||||
"paysdomicile",
|
# "paysdomicile",
|
||||||
"telephonemobile",
|
# "telephonemobile",
|
||||||
"typeadresse",
|
# "typeadresse",
|
||||||
]
|
# ]
|
||||||
|
#
|
||||||
r = requests.get(
|
# r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiants",
|
# SCODOC_URL + "/ScoDoc/api/etudiants",
|
||||||
headers=HEADERS,
|
# headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
# verify=CHECK_CERTIFICATE,
|
||||||
)
|
# )
|
||||||
assert r.status_code == 200
|
# assert r.status_code == 200
|
||||||
assert len(r.json()) == 16
|
# assert len(r.json()) == 16
|
||||||
|
#
|
||||||
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
# # Choisis aléatoirement un étudiant dans la liste des étudiants
|
||||||
etu = r.json()[randint(0, len(r.json())) - 1]
|
# etu = r.json()[randint(0, len(r.json())) - 1]
|
||||||
|
#
|
||||||
fields_OK = True
|
# fields_OK = True
|
||||||
|
#
|
||||||
# Vérifie si tous les champs sont bien présents
|
# # Vérifie si tous les champs sont bien présents
|
||||||
for field in etu:
|
# for field in etu:
|
||||||
if field not in fields:
|
# if field not in fields:
|
||||||
fields_OK = False
|
# fields_OK = False
|
||||||
|
#
|
||||||
assert fields_OK is True
|
# assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# etudiants_courant
|
# etudiants_courant
|
||||||
@ -180,7 +180,8 @@ def test_etudiant(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 24
|
assert len(r.json()) == 24
|
||||||
@ -200,7 +201,8 @@ def test_etudiant(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 24
|
assert len(r.json()) == 24
|
||||||
@ -269,12 +271,12 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
######### Test code nip #########
|
######### Test code nip #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestres",
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestres",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
@ -294,7 +296,8 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestres",
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestres",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
@ -311,89 +314,89 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
#etudiant_bulletin_semestre
|
# etudiant_bulletin_semestre
|
||||||
def test_etudiant_bulletin_semestre():
|
def test_etudiant_bulletin_semestre():
|
||||||
|
|
||||||
fields = [
|
# fields = [
|
||||||
"etudid",
|
# "etudid",
|
||||||
"formsemestre_id",
|
# "formsemestre_id",
|
||||||
"date",
|
# "date",
|
||||||
"publie",
|
# "publie",
|
||||||
"etapes",
|
# "etapes",
|
||||||
"etudiant",
|
# "etudiant",
|
||||||
"note",
|
# "note",
|
||||||
"rang",
|
# "rang",
|
||||||
"rang_group",
|
# "rang_group",
|
||||||
"note_max",
|
# "note_max",
|
||||||
"bonus_sport_culture",
|
# "bonus_sport_culture",
|
||||||
"ue",
|
# "ue",
|
||||||
"ue_capitalisee",
|
# "ue_capitalisee",
|
||||||
"absences",
|
# "absences",
|
||||||
"appreciation",
|
# "appreciation",
|
||||||
]
|
# ]
|
||||||
|
|
||||||
######### Test etudid #########
|
######### Test etudid #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 15
|
assert len(r.json()) == 13
|
||||||
|
|
||||||
bulletin = r.json()
|
|
||||||
|
|
||||||
fields_OK = True
|
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in bulletin:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
|
||||||
|
|
||||||
|
# bulletin = r.json()
|
||||||
|
#
|
||||||
|
# fields_OK = True
|
||||||
|
#
|
||||||
|
# # Vérifie si tous les champs sont bien présents
|
||||||
|
# for field in bulletin:
|
||||||
|
# if field not in fields:
|
||||||
|
# fields_OK = False
|
||||||
|
#
|
||||||
|
# assert fields_OK is True
|
||||||
|
|
||||||
######### Test code nip #########
|
######### Test code nip #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestre/1/bulletin",
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestre/1/bulletin",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 15
|
assert len(r.json()) == 13
|
||||||
|
|
||||||
bulletin = r.json()
|
|
||||||
|
|
||||||
fields_OK = True
|
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in bulletin:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
|
||||||
|
|
||||||
|
# bulletin = r.json()
|
||||||
|
#
|
||||||
|
# fields_OK = True
|
||||||
|
#
|
||||||
|
# # Vérifie si tous les champs sont bien présents
|
||||||
|
# for field in bulletin:
|
||||||
|
# if field not in fields:
|
||||||
|
# fields_OK = False
|
||||||
|
#
|
||||||
|
# assert fields_OK is True
|
||||||
|
|
||||||
######### Test code ine #########
|
######### Test code ine #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestre/1/bulletin",
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestre/1/bulletin",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 15
|
assert len(r.json()) == 13
|
||||||
|
|
||||||
bulletin = r.json()
|
|
||||||
|
|
||||||
fields_OK = True
|
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in bulletin:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
|
||||||
|
|
||||||
|
# bulletin = r.json()
|
||||||
|
#
|
||||||
|
# fields_OK = True
|
||||||
|
#
|
||||||
|
# # Vérifie si tous les champs sont bien présents
|
||||||
|
# for field in bulletin:
|
||||||
|
# if field not in fields:
|
||||||
|
# fields_OK = False
|
||||||
|
#
|
||||||
|
# assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# etudiant_groups
|
# etudiant_groups
|
||||||
@ -411,7 +414,6 @@ def test_etudiant_groups():
|
|||||||
"group_name",
|
"group_name",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
######### Test etudid #########
|
######### Test etudid #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
@ -433,13 +435,12 @@ def test_etudiant_groups():
|
|||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######### Test code nip #########
|
######### Test code nip #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/semestre/1/groups",
|
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/semestre/1/groups",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
@ -459,7 +460,8 @@ def test_etudiant_groups():
|
|||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/semestre/1/groups",
|
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/semestre/1/groups",
|
||||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
headers=HEADERS,
|
||||||
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user