forked from ScoDoc/DocScoDoc
Merge branch 'api' of https://scodoc.org/git/leonard.montalbano/ScoDoc into new_api
This commit is contained in:
commit
c580d98414
@ -23,4 +23,14 @@ def requested_format(default_format="json", allowed_formats=None):
|
|||||||
|
|
||||||
from app.api import tokens
|
from app.api import tokens
|
||||||
from app.api import sco_api
|
from app.api import sco_api
|
||||||
|
from app.api import test_api
|
||||||
|
from app.api import departements
|
||||||
|
from app.api import etudiants
|
||||||
|
from app.api import formations
|
||||||
|
from app.api import formsemestres
|
||||||
|
from app.api import partitions
|
||||||
|
from app.api import evaluations
|
||||||
|
from app.api import jury
|
||||||
|
from app.api import absences
|
||||||
from app.api import logos
|
from app.api import logos
|
||||||
|
|
||||||
|
315
app/api/absences.py
Normal file
315
app/api/absences.py
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
#################################################### Absences #########################################################
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.auth import token_auth
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_abs import add_absence, add_justif, annule_absence, annule_justif, list_abs_date
|
||||||
|
from app.scodoc.sco_groups import get_group_members
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/absences/etudid/<int:etudid>", methods=["GET"])
|
||||||
|
@bp.route("/absences/nip/<int:nip>", methods=["GET"])
|
||||||
|
@bp.route("/absences/ine/<int:ine>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def absences(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des absences d'un étudiant donné
|
||||||
|
|
||||||
|
etudid : l'etudid d'un étudiant
|
||||||
|
nip: le code nip d'un étudiant
|
||||||
|
ine : le code ine d'un étudiant
|
||||||
|
"""
|
||||||
|
abs = None
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
# Récupération des absences de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etudid).all()
|
||||||
|
else:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
# Récupération des absences de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etu.etudid).all()
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
# Récupération des absences de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etu.etudid).all()
|
||||||
|
|
||||||
|
if abs is not None: # Si des absences ont bien été trouvé
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in abs]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/absences/etudid/<int:etudid>/abs_just_only", methods=["GET"])
|
||||||
|
@bp.route("/absences/nip/<int:nip>/abs_just_only", methods=["GET"])
|
||||||
|
@bp.route("/absences/ine/<int:ine>/abs_just_only", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des absences justifiées d'un étudiant donné
|
||||||
|
|
||||||
|
etudid : l'etudid d'un étudiant
|
||||||
|
nip: le code nip d'un étudiant
|
||||||
|
ine : le code ine d'un étudiant
|
||||||
|
"""
|
||||||
|
abs = None
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
# Récupération des absences justifiées de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True).all()
|
||||||
|
else:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
# Récupération des absences justifiées de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etu.etudid, estjust=True).all()
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
# Récupération des absences justifiées de l'étudiant
|
||||||
|
abs = models.Absence.query.filter_by(etudid=etu.etudid, estjust=True).all()
|
||||||
|
|
||||||
|
if abs is not None: # Si des absences ont bien été trouvé
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in abs]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@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_auth.login_required
|
||||||
|
@permission_required(Permission.APIAbsChange)
|
||||||
|
def abs_signale(date: datetime, matin: bool, justif: bool, etudid: int = None, nip: int = None, ine: int = None,
|
||||||
|
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 description is not None: # Si la description a été renseignée
|
||||||
|
if moduleimpl_id is not None: # Si le moduleimpl a été renseigné
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etudid, date, matin, justif, description, moduleimpl_id)
|
||||||
|
# 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")
|
||||||
|
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif, description, moduleimpl_id)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin, description)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif, description, moduleimpl_id)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin, description)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
else: # Si le moduleimpl n'a pas été renseigné
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etudid, date, matin, justif, description)
|
||||||
|
# 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")
|
||||||
|
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif, description)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin, description)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif, description)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin, description)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
else:
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etudid, date, matin, justif)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etudid, date, matin)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction add_absence
|
||||||
|
add_absence(etu.etudid, date, matin, justif)
|
||||||
|
# Utilisation de la fonction add_justif
|
||||||
|
add_justif(etu.etudid, date, matin)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return error_response(200, message="OK")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@bp.route("/absences/abs_annule?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@bp.route("/absences/abs_annule?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIAbsChange)
|
||||||
|
def abs_annule(jour: datetime, matin: str, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne un html
|
||||||
|
|
||||||
|
jour : la date de l'absence a annulé
|
||||||
|
matin : True ou False
|
||||||
|
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_abs.annule_absence()
|
||||||
|
|
||||||
|
if etudid is None:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
# Récupération de l'etudid de l'étudiant
|
||||||
|
etudid = etu.etudid
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
# Récupération de l'etudid de l'étudiant
|
||||||
|
etudid = etu.etudid
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction annule_absence
|
||||||
|
annule_absence(etudid, jour, matin)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return error_response(200, message="OK")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/absences/abs_annule_justif?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@bp.route("/absences/abs_annule_justif?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@bp.route("/absences/abs_annule_justif?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
|
||||||
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIAbsChange)
|
||||||
|
def abs_annule_justif(jour: datetime, matin: str, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne un html
|
||||||
|
|
||||||
|
jour : la date de l'absence a annulé
|
||||||
|
matin : True ou False
|
||||||
|
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_abs.annule_justif()
|
||||||
|
|
||||||
|
if etudid is None:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
# Récupération de l'etudid de l'étudiant
|
||||||
|
etudid = etu.etudid
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
# Récupération de l'etudid de l'étudiant
|
||||||
|
etudid = etu.etudid
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction annule_justif
|
||||||
|
annule_justif(etudid, jour, matin)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return error_response(200, message="OK")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def abs_groupe_etat(group_id: int, date_debut, date_fin, with_boursier=True, format="html"):
|
||||||
|
"""
|
||||||
|
Retoune la liste des absences d'un ou plusieurs groupes entre deux dates
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_groups.get_group_members() et app.scodoc.sco_abs.list_abs_date()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction get_group_members
|
||||||
|
members = get_group_members(group_id)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
data = []
|
||||||
|
# Filtre entre les deux dates renseignées
|
||||||
|
for member in members:
|
||||||
|
abs = list_abs_date(member.id, date_debut, date_fin)
|
||||||
|
data.append(abs)
|
||||||
|
|
||||||
|
# return jsonify(data) # XXX TODO faire en sorte de pouvoir renvoyer sa (ex to_dict() dans absences)
|
||||||
|
return error_response(501, message="Not implemented")
|
191
app/api/departements.py
Normal file
191
app/api/departements.py
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
############################################### Departements ##########################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.auth import token_auth
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.models import ApcReferentielCompetences
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
from app.scodoc.sco_prepajury import feuille_preparation_jury
|
||||||
|
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
||||||
|
from app.scodoc.sco_recapcomplet import formsemestre_recapcomplet
|
||||||
|
from app.scodoc.sco_saisie_notes import notes_add
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/departements", methods=["GET"])
|
||||||
|
@token_auth.login_required # Commenté le temps des tests
|
||||||
|
# @permission_required(Permission.ScoView)
|
||||||
|
def departements():
|
||||||
|
"""
|
||||||
|
Retourne la liste des ids de départements visibles
|
||||||
|
|
||||||
|
Exemple de résultat : [2, 5, 8, 1, 4, 18]
|
||||||
|
"""
|
||||||
|
# Récupération de tous les départements
|
||||||
|
depts = models.Departement.query.filter_by(visible=True).all()
|
||||||
|
|
||||||
|
# Mise en place de la liste avec tous les ids de départements
|
||||||
|
depts_ids = [d.id for d in depts]
|
||||||
|
|
||||||
|
return jsonify(depts_ids)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/departements/<string:dept>/etudiants/liste", methods=["GET"])
|
||||||
|
@bp.route("/departements/<string:dept>/etudiants/liste/<int:formsemestre_id>", methods=["GET"])
|
||||||
|
@token_auth.login_required
|
||||||
|
# @permission_required(Permission.APIView)
|
||||||
|
def liste_etudiants(dept: str, formsemestre_id=None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des étudiants d'un département
|
||||||
|
|
||||||
|
dept: l'acronym d'un département
|
||||||
|
formsemestre_id: l'id d'un formesemestre
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 18,
|
||||||
|
"nom": "MOREL",
|
||||||
|
"prenom": "JACQUES"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 19,
|
||||||
|
"nom": "FOURNIER",
|
||||||
|
"prenom": "ANNE"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
"""
|
||||||
|
# Si le formsemestre_id a été renseigné
|
||||||
|
if formsemestre_id is not None:
|
||||||
|
# Récupération du formsemestre
|
||||||
|
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
||||||
|
# Récupération du département
|
||||||
|
departement = formsemestre.departement
|
||||||
|
# Récupération des étudiants
|
||||||
|
etudiants = departement.etudiants.all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
list_etu = [etu.to_dict_bul(include_urls=False) for etu in etudiants]
|
||||||
|
|
||||||
|
# Si le formsemestre_id n'a pas été renseigné
|
||||||
|
else:
|
||||||
|
# Récupération du formsemestre
|
||||||
|
departement = models.Departement.query.filter_by(acronym=dept).first()
|
||||||
|
# Récupération des étudiants
|
||||||
|
etudiants = departement.etudiants.all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
list_etu = [etu.to_dict_bul(include_urls=False) for etu in etudiants]
|
||||||
|
|
||||||
|
return jsonify(list_etu)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/departements/<string:dept>/semestres_courants", methods=["GET"])
|
||||||
|
# @token_auth.login_required # Commenté le temps des tests
|
||||||
|
# @permission_required(Permission.APIView)
|
||||||
|
def liste_semestres_courant(dept: str):
|
||||||
|
"""
|
||||||
|
Liste des semestres actifs d'un départements donné
|
||||||
|
|
||||||
|
dept: l'acronym d'un département
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"titre": "master machine info",
|
||||||
|
"gestion_semestrielle": false,
|
||||||
|
"scodoc7_id": null,
|
||||||
|
"date_debut": "01/09/2021",
|
||||||
|
"bul_bgcolor": null,
|
||||||
|
"date_fin": "15/12/2022",
|
||||||
|
"resp_can_edit": false,
|
||||||
|
"dept_id": 1,
|
||||||
|
"etat": true,
|
||||||
|
"resp_can_change_ens": false,
|
||||||
|
"id": 1,
|
||||||
|
"modalite": "FI",
|
||||||
|
"ens_can_edit_eval": false,
|
||||||
|
"formation_id": 1,
|
||||||
|
"gestion_compensation": false,
|
||||||
|
"elt_sem_apo": null,
|
||||||
|
"semestre_id": 1,
|
||||||
|
"bul_hide_xml": false,
|
||||||
|
"elt_annee_apo": null,
|
||||||
|
"block_moyennes": false,
|
||||||
|
"formsemestre_id": 1,
|
||||||
|
"titre_num": "master machine info semestre 1",
|
||||||
|
"date_debut_iso": "2021-09-01",
|
||||||
|
"date_fin_iso": "2022-12-15",
|
||||||
|
"responsables": [
|
||||||
|
3,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
# Récupération des départements comportant l'acronym mit en paramètre
|
||||||
|
depts = models.Departement.query.filter_by(acronym=dept).all()
|
||||||
|
|
||||||
|
# Récupération de l'id
|
||||||
|
id_dept = depts[0].id
|
||||||
|
|
||||||
|
# Récupération des semestres suivant id_dept
|
||||||
|
semestres = models.FormSemestre.query.filter_by(dept_id=id_dept, etat=True).all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
|
||||||
|
data = [d.to_dict() for d in semestres]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/departements/<string:dept>/formations/<int:formation_id>/referentiel_competences", methods=["GET"])
|
||||||
|
# @permission_required(Permission.APIView)
|
||||||
|
def referenciel_competences(dept: str, formation_id: int):
|
||||||
|
"""
|
||||||
|
Retourne le référentiel de compétences
|
||||||
|
|
||||||
|
dept : l'acronym d'un département
|
||||||
|
formation_id : l'id d'une formation
|
||||||
|
"""
|
||||||
|
depts = models.Departement.query.filter_by(acronym=dept).all()
|
||||||
|
|
||||||
|
id_dept = depts[0].id
|
||||||
|
|
||||||
|
formations = models.Formation.query.filter_by(id=formation_id, dept_id=id_dept).all()
|
||||||
|
|
||||||
|
ref_comp = formations[0].referentiel_competence_id
|
||||||
|
|
||||||
|
if ref_comp is None:
|
||||||
|
return error_response(204, message="Pas de référenciel de compétences pour cette formation")
|
||||||
|
else:
|
||||||
|
return jsonify(ref_comp)
|
||||||
|
|
||||||
|
# ref = ApcReferentielCompetences.query.get_or_404(formation_id)
|
||||||
|
#
|
||||||
|
# return jsonify(ref.to_dict())
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/departements/<string:dept>/formsemestre/<string:formsemestre_id>/programme", methods=["GET"])
|
||||||
|
# @permission_required(Permission.APIView)
|
||||||
|
def semestre_index(dept: str, formsemestre_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste des Ues, ressources et SAE d'un semestre
|
||||||
|
"""
|
||||||
|
|
||||||
|
return error_response(501, message="not implemented")
|
324
app/api/etudiants.py
Normal file
324
app/api/etudiants.py
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
#################################################### Etudiants ########################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
||||||
|
from app.scodoc.sco_groups import get_etud_groups
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiants", methods=["GET"])
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiants():
|
||||||
|
"""
|
||||||
|
Retourne la liste de tous les étudiants
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 18,
|
||||||
|
"nom": "MOREL",
|
||||||
|
"prenom": "JACQUES"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 19,
|
||||||
|
"nom": "FOURNIER",
|
||||||
|
"prenom": "ANNE"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
"""
|
||||||
|
# Récupération de tous les étudiants
|
||||||
|
etu = models.Identite.query.all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict_bul(include_urls=False) for d in etu]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiants/courant", methods=["GET"])
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiants_courant():
|
||||||
|
"""
|
||||||
|
Retourne la liste des étudiants courant
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 18,
|
||||||
|
"nom": "MOREL",
|
||||||
|
"prenom": "JACQUES"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 19,
|
||||||
|
"nom": "FOURNIER",
|
||||||
|
"prenom": "ANNE"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
"""
|
||||||
|
# Récupération de tous les étudiants
|
||||||
|
etus = models.Identite.query.all()
|
||||||
|
|
||||||
|
data = []
|
||||||
|
# Récupère uniquement les étudiants courant
|
||||||
|
for etu in etus:
|
||||||
|
if etu.inscription_courante() is not None:
|
||||||
|
data.append(etu.to_dict_bul(include_urls=False))
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiant/etudid/<int:etudid>", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/nip/<int:nip>", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/ine/<int:ine>", methods=["GET"])
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne les informations de l'étudiant correspondant à l'id passé en paramètres.
|
||||||
|
|
||||||
|
etudid : l'etudid d'un étudiant
|
||||||
|
nip : le code nip d'un étudiant
|
||||||
|
ine : le code ine d'un étudiant
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
{
|
||||||
|
"civilite": "X",
|
||||||
|
"code_ine": null,
|
||||||
|
"code_nip": null,
|
||||||
|
"date_naissance": null,
|
||||||
|
"email": null,
|
||||||
|
"emailperso": null,
|
||||||
|
"etudid": 18,
|
||||||
|
"nom": "MOREL",
|
||||||
|
"prenom": "JACQUES"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
etu = []
|
||||||
|
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(id=etudid).first()
|
||||||
|
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = etu.to_dict_bul(include_urls=False)
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiant/etudid/<int:etudid>/formsemestres")
|
||||||
|
@bp.route("/etudiant/nip/<int:nip>/formsemestres")
|
||||||
|
@bp.route("/etudiant/ine/<int:ine>/formsemestres")
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des semestres qu'un étudiant a suivis
|
||||||
|
|
||||||
|
etudid : l'etudid d'un étudiant
|
||||||
|
nip : le code nip d'un étudiant
|
||||||
|
ine : le code ine d'un étudiant
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"titre": "master machine info",
|
||||||
|
"gestion_semestrielle": false,
|
||||||
|
"scodoc7_id": null,
|
||||||
|
"date_debut": "01/09/2021",
|
||||||
|
"bul_bgcolor": null,
|
||||||
|
"date_fin": "15/12/2022",
|
||||||
|
"resp_can_edit": false,
|
||||||
|
"dept_id": 1,
|
||||||
|
"etat": true,
|
||||||
|
"resp_can_change_ens": false,
|
||||||
|
"id": 1,
|
||||||
|
"modalite": "FI",
|
||||||
|
"ens_can_edit_eval": false,
|
||||||
|
"formation_id": 1,
|
||||||
|
"gestion_compensation": false,
|
||||||
|
"elt_sem_apo": null,
|
||||||
|
"semestre_id": 1,
|
||||||
|
"bul_hide_xml": false,
|
||||||
|
"elt_annee_apo": null,
|
||||||
|
"block_moyennes": false,
|
||||||
|
"formsemestre_id": 1,
|
||||||
|
"titre_num": "master machine info semestre 1",
|
||||||
|
"date_debut_iso": "2021-09-01",
|
||||||
|
"date_fin_iso": "2022-12-15",
|
||||||
|
"responsables": [
|
||||||
|
3,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Récupération de toutes les inscriptions
|
||||||
|
inscriptions = models.FormSemestreInscription.query.all()
|
||||||
|
|
||||||
|
sems = []
|
||||||
|
# Filtre les inscriptions contenant l'étudiant
|
||||||
|
for sem in inscriptions:
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
if sem.etudid == etudid:
|
||||||
|
sems.append(sem)
|
||||||
|
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
if sem.etudid == etu.etudid:
|
||||||
|
sems.append(sem)
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).firt()
|
||||||
|
if sem.etudid == etu.etudid:
|
||||||
|
sems.append(sem)
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
# data_inscriptions = [d.to_dict() for d in sems]
|
||||||
|
|
||||||
|
formsemestres = []
|
||||||
|
|
||||||
|
# Filtre les formsemestre contenant les inscriptions de l'étudiant
|
||||||
|
for sem in sems:#data_inscriptions:
|
||||||
|
res = models.FormSemestre.query.filter_by(id=sem.formsemestre_id).first()
|
||||||
|
formsemestres.append(res)
|
||||||
|
|
||||||
|
data = []
|
||||||
|
# Mise en forme des données
|
||||||
|
for formsem in formsemestres:
|
||||||
|
data.append(formsem.to_dict())
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiant_bulletin_semestre(formsemestre_id, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne le bulletin d'un étudiant en fonction de son id et d'un semestre donné
|
||||||
|
|
||||||
|
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_json.make_json_formsemestre_bulletinetud()
|
||||||
|
|
||||||
|
etu = None
|
||||||
|
if etudid is not None: # Si route etudid
|
||||||
|
return make_json_formsemestre_bulletinetud(formsemestre_id, etudid)
|
||||||
|
else:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=ine).first()
|
||||||
|
|
||||||
|
if etu is not None: # Si route nip ou ine
|
||||||
|
return make_json_formsemestre_bulletinetud(formsemestre_id, etu.etudid)
|
||||||
|
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiant/etudid/<int:etudid>/semestre/<int:formsemestre_id>/groups", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/nip/<int:nip>/semestre/<int:formsemestre_id>/groups", methods=["GET"])
|
||||||
|
@bp.route("/etudiant/ine/<int:ine>/semestre/<int:formsemestre_id>/groups", methods=["GET"])
|
||||||
|
#@permission_required(Permission.APIView)
|
||||||
|
def etudiant_groups(formsemestre_id: int, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des groupes auxquels appartient l'étudiant dans le semestre indiqué
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Exemple de résultat :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"partition_id": 1,
|
||||||
|
"id": 1,
|
||||||
|
"formsemestre_id": 1,
|
||||||
|
"partition_name": null,
|
||||||
|
"numero": 0,
|
||||||
|
"bul_show_rank": false,
|
||||||
|
"show_in_lists": true,
|
||||||
|
"group_id": 1,
|
||||||
|
"group_name": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"partition_id": 2,
|
||||||
|
"id": 2,
|
||||||
|
"formsemestre_id": 1,
|
||||||
|
"partition_name": "TD",
|
||||||
|
"numero": 1,
|
||||||
|
"bul_show_rank": false,
|
||||||
|
"show_in_lists": true,
|
||||||
|
"group_id": 2,
|
||||||
|
"group_name": "A"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_groups.get_etud_groups()
|
||||||
|
|
||||||
|
if etudid is None:
|
||||||
|
if nip is not None: # Si route nip
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_nip=nip).first()
|
||||||
|
# Récupération de sont etudid
|
||||||
|
etudid = etu.etudid
|
||||||
|
|
||||||
|
if ine is not None: # Si route ine
|
||||||
|
# Récupération de l'étudiant
|
||||||
|
etu = models.Identite.query.filter_by(code_ine=ine).first()
|
||||||
|
# Récupération de sont etudid
|
||||||
|
etudid = etu.etudid
|
||||||
|
|
||||||
|
# Récupération du formsemestre
|
||||||
|
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction get_etud_groups
|
||||||
|
data = get_etud_groups(etudid, sem.to_dict())
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return jsonify(data)
|
69
app/api/evaluations.py
Normal file
69
app/api/evaluations.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
############################################### Evaluations ###########################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.auth import token_auth
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/evaluations/<int:moduleimpl_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def evaluations(moduleimpl_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste des évaluations à partir de l'id d'un moduleimpl
|
||||||
|
|
||||||
|
moduleimpl_id : l'id d'un moduleimpl
|
||||||
|
"""
|
||||||
|
# Récupération de toutes les évaluations
|
||||||
|
evals = models.Evaluation.query.filter_by(id=moduleimpl_id).all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in evals]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/evaluations/eval_notes/<int:evaluation_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def evaluation_notes(evaluation_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste des notes à partir de l'id d'une évaluation donnée
|
||||||
|
|
||||||
|
evaluation_id : l'id d'une évaluation
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_evaluation_db.do_evaluation_get_all_notes()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction do_evaluation_get_all_notes
|
||||||
|
data = do_evaluation_get_all_notes(evaluation_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("/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<float:note>", methods=["POST"])
|
||||||
|
@bp.route("/evaluations/eval_set_notes?eval_id=<int:eval_id>&nip=<int:nip>¬e=<float:note>", methods=["POST"])
|
||||||
|
@bp.route("/evaluations/eval_set_notes?eval_id=<int:eval_id>&ine=<int:ine>¬e=<float:note>", methods=["POST"])
|
||||||
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIEditAllNotes)
|
||||||
|
def evaluation_set_notes(eval_id: int, note: float, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Set les notes d'une évaluation pour un étudiant donnée
|
||||||
|
|
||||||
|
eval_id : l'id d'une évaluation
|
||||||
|
note : la note à attribuer
|
||||||
|
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_saisie_notes.notes_add()
|
||||||
|
|
||||||
|
# Qu'est ce qu'un user ???
|
||||||
|
# notes_add()
|
||||||
|
return error_response(501, message="Not implemented")
|
117
app/api/formations.py
Normal file
117
app/api/formations.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
##############################################" Formations ############################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_formations import formation_export
|
||||||
|
from app.scodoc.sco_moduleimpl import moduleimpl_list
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/formations", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def formations():
|
||||||
|
"""
|
||||||
|
Retourne la liste des formations
|
||||||
|
"""
|
||||||
|
# Récupération de toutes les formations
|
||||||
|
list_formations = models.Formation.query.all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in list_formations]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/formations/<int:formation_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def formations_by_id(formation_id: int):
|
||||||
|
"""
|
||||||
|
Retourne une formation en fonction d'un id donné
|
||||||
|
|
||||||
|
formation_id : l'id d'une formation
|
||||||
|
"""
|
||||||
|
# Récupération de la formation
|
||||||
|
forma = models.Formation.query.filter_by(id=formation_id).first()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in forma]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/formations/formation_export/<int:formation_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def formation_export_by_formation_id(formation_id: int, export_ids=False):
|
||||||
|
"""
|
||||||
|
Retourne la formation, avec UE, matières, modules
|
||||||
|
"""
|
||||||
|
# Fonction utilité : app.scodoc.sco_formations.formation_export()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction formation_export
|
||||||
|
data = formation_export(formation_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("/formations/apo/<string:etape_apo>", methods=["GET"])
|
||||||
|
@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).all()
|
||||||
|
|
||||||
|
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()
|
||||||
|
data.append(formsem.to_dict())
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def moduleimpls(moduleimpl_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste des moduleimpl
|
||||||
|
|
||||||
|
moduleimpl_id : l'id d'un moduleimpl
|
||||||
|
"""
|
||||||
|
# Récupération des tous les moduleimpl
|
||||||
|
list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id).all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = list_moduleimpls[0].to_dict()
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def moduleimpls_sem(moduleimpl_id: int, formsemestre_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste des moduleimpl d'un semestre
|
||||||
|
|
||||||
|
moduleimpl_id : l'id d'un moduleimpl
|
||||||
|
formsemestre_id : l'id d'un formsemestre
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_moduleimpl.moduleimpl_list()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction moduleimpl_list
|
||||||
|
data = moduleimpl_list(moduleimpl_id, formsemestre_id)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return jsonify(data)
|
104
app/api/formsemestres.py
Normal file
104
app/api/formsemestres.py
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
########################################## Formsemestres ##############################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
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"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
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"],
|
||||||
|
)
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
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"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
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"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
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)
|
75
app/api/jury.py
Normal file
75
app/api/jury.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#################################################### Jury #############################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.scodoc.sco_prepajury import feuille_preparation_jury
|
||||||
|
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/jury/formsemestre/<int:formsemestre_id>/preparation_jury", methods=["GET"])
|
||||||
|
def jury_preparation(formsemestre_id: int): # XXX TODO check à quoi resemble le retour de la fonction
|
||||||
|
"""
|
||||||
|
Retourne la feuille de préparation du jury
|
||||||
|
|
||||||
|
formsemestre_id : l'id d'un formsemestre
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_prepajury.feuille_preparation_jury()
|
||||||
|
|
||||||
|
# Utilisation de la fonction feuille_preparation_jury
|
||||||
|
prepa_jury = feuille_preparation_jury(formsemestre_id)
|
||||||
|
|
||||||
|
return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/jury/formsemestre/<int:formsemestre_id>/decisions_jury", methods=["GET"])
|
||||||
|
def jury_decisions(formsemestre_id: int): # XXX TODO check à quoi resemble le retour de la fonction
|
||||||
|
"""
|
||||||
|
Retourne les décisions du jury suivant un formsemestre donné
|
||||||
|
|
||||||
|
formsemestre_id : l'id d'un formsemestre
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_pvjury.formsemestre_pvjury()
|
||||||
|
|
||||||
|
# Utilisation de la fonction formsemestre_pvjury
|
||||||
|
decision_jury = formsemestre_pvjury(formsemestre_id)
|
||||||
|
|
||||||
|
return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/jury/set_decision/etudid?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>", methods=["POST"])
|
||||||
|
@bp.route("/jury/set_decision/nip?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>", methods=["POST"])
|
||||||
|
@bp.route("/jury/set_decision/ine?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>", methods=["POST"])
|
||||||
|
def set_decision_jury(formsemestre_id: int, decision_jury: str, devenir_jury: str, assiduite: bool,
|
||||||
|
etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Attribuer la décision du jury et le devenir à un etudiant
|
||||||
|
|
||||||
|
formsemestre_id : l'id d'un formsemestre
|
||||||
|
decision_jury : la décision du jury
|
||||||
|
devenir_jury : le devenir du jury
|
||||||
|
assiduite : True ou False
|
||||||
|
etudid : l'etudid d'un étudiant
|
||||||
|
nip: le code nip d'un étudiant
|
||||||
|
ine : le code ine d'un étudiant
|
||||||
|
"""
|
||||||
|
return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/jury/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/annule_decision", methods=["DELETE"])
|
||||||
|
@bp.route("/jury/nip/<int:nip>/formsemestre/<int:formsemestre_id>/annule_decision", methods=["DELETE"])
|
||||||
|
@bp.route("/jury/ine/<int:ine>/formsemestre/<int:formsemestre_id>/annule_decision", methods=["DELETE"])
|
||||||
|
def annule_decision_jury(formsemestre_id: int, etudid: int = None, nip: int = None, ine: int = None):
|
||||||
|
"""
|
||||||
|
Supprime la déciosion du jury pour un étudiant donné
|
||||||
|
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
return error_response(501, message="Not implemented")
|
@ -36,6 +36,7 @@ from app.api import bp
|
|||||||
from app.api import requested_format
|
from app.api import requested_format
|
||||||
from app.api.auth import token_auth
|
from app.api.auth import token_auth
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
from app.models import Departement
|
from app.models import Departement
|
||||||
from app.scodoc.sco_logos import list_logos, find_logo
|
from app.scodoc.sco_logos import list_logos, find_logo
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
@ -43,6 +44,7 @@ from app.scodoc.sco_permissions import Permission
|
|||||||
|
|
||||||
@bp.route("/logos", methods=["GET"])
|
@bp.route("/logos", methods=["GET"])
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
def api_get_glob_logos():
|
def api_get_glob_logos():
|
||||||
if not g.current_user.has_permission(Permission.ScoSuperAdmin, None):
|
if not g.current_user.has_permission(Permission.ScoSuperAdmin, None):
|
||||||
return error_response(401, message="accès interdit")
|
return error_response(401, message="accès interdit")
|
||||||
@ -55,6 +57,7 @@ def api_get_glob_logos():
|
|||||||
|
|
||||||
@bp.route("/logos/<string:logoname>", methods=["GET"])
|
@bp.route("/logos/<string:logoname>", methods=["GET"])
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
def api_get_glob_logo(logoname):
|
def api_get_glob_logo(logoname):
|
||||||
if not g.current_user.has_permission(Permission.ScoSuperAdmin, None):
|
if not g.current_user.has_permission(Permission.ScoSuperAdmin, None):
|
||||||
return error_response(401, message="accès interdit")
|
return error_response(401, message="accès interdit")
|
||||||
@ -71,6 +74,7 @@ def api_get_glob_logo(logoname):
|
|||||||
|
|
||||||
@bp.route("/departements/<string:departement>/logos", methods=["GET"])
|
@bp.route("/departements/<string:departement>/logos", methods=["GET"])
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
def api_get_local_logos(departement):
|
def api_get_local_logos(departement):
|
||||||
dept_id = Departement.from_acronym(departement).id
|
dept_id = Departement.from_acronym(departement).id
|
||||||
if not g.current_user.has_permission(Permission.ScoChangePreferences, departement):
|
if not g.current_user.has_permission(Permission.ScoChangePreferences, departement):
|
||||||
@ -81,6 +85,7 @@ def api_get_local_logos(departement):
|
|||||||
|
|
||||||
@bp.route("/departements/<string:departement>/logos/<string:logoname>", methods=["GET"])
|
@bp.route("/departements/<string:departement>/logos/<string:logoname>", methods=["GET"])
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
def api_get_local_logo(departement, logoname):
|
def api_get_local_logo(departement, logoname):
|
||||||
# format = requested_format("jpg", ['png', 'jpg']) XXX ?
|
# format = requested_format("jpg", ['png', 'jpg']) XXX ?
|
||||||
dept_id = Departement.from_acronym(departement).id
|
dept_id = Departement.from_acronym(departement).id
|
||||||
|
84
app/api/partitions.py
Normal file
84
app/api/partitions.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
############################################### Partitions ############################################################
|
||||||
|
from flask import jsonify
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp
|
||||||
|
from app.api.auth import token_auth
|
||||||
|
from app.api.errors import error_response
|
||||||
|
from app.decorators import permission_required
|
||||||
|
from app.scodoc.sco_groups import get_group_members, setGroups
|
||||||
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/partitions/<int:formsemestre_id>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def partition(formsemestre_id: int):
|
||||||
|
"""
|
||||||
|
Retourne la liste de toutes les partitions d'un formsemestre
|
||||||
|
|
||||||
|
formsemestre_id : l'id d'un formsemestre
|
||||||
|
"""
|
||||||
|
# Récupération de toutes les partitions
|
||||||
|
partitions = models.Partition.query.filter_by(id=formsemestre_id).all()
|
||||||
|
|
||||||
|
# Mise en forme des données
|
||||||
|
data = [d.to_dict() for d in partitions]
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
# return error_response(501, message="Not implemented")
|
||||||
|
|
||||||
|
|
||||||
|
# @bp.route(
|
||||||
|
# "/partitions/formsemestre/<int:formsemestre_id>/groups/group_ids?with_codes=&all_groups=&etat=",
|
||||||
|
# methods=["GET"],
|
||||||
|
# )
|
||||||
|
@bp.route("/partitions/groups/<int:group_id>", methods=["GET"])
|
||||||
|
@bp.route("/partitions/groups/<int:group_id>/etat/<string:etat>", methods=["GET"])
|
||||||
|
@permission_required(Permission.APIView)
|
||||||
|
def etud_in_group(group_id: int, etat=None):
|
||||||
|
"""
|
||||||
|
Retourne la liste des étudiants dans un groupe
|
||||||
|
|
||||||
|
group_id : l'id d'un groupe
|
||||||
|
etat :
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_groups.get_group_members()
|
||||||
|
|
||||||
|
if etat is None: # Si l'état n'est pas renseigné
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction get_group_members
|
||||||
|
data = get_group_members(group_id)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
else: # Si l'état est renseigné
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction get_group_members
|
||||||
|
data = get_group_members(group_id, etat)
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route(
|
||||||
|
"/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&"
|
||||||
|
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>", methods=["POST"],
|
||||||
|
)
|
||||||
|
@token_auth.login_required
|
||||||
|
@permission_required(Permission.APIEtudChangeGroups)
|
||||||
|
def set_groups(partition_id: int, groups_lists: int, groups_to_delete: int, groups_to_create: int):
|
||||||
|
"""
|
||||||
|
Set les groups
|
||||||
|
|
||||||
|
partition_id : l'id d'une partition
|
||||||
|
groups_lists :
|
||||||
|
groups_ti_delete : les groupes à supprimer
|
||||||
|
groups_to_create : les groupes à créer
|
||||||
|
"""
|
||||||
|
# Fonction utilisée : app.scodoc.sco_groups.setGroups()
|
||||||
|
try:
|
||||||
|
# Utilisation de la fonction setGroups
|
||||||
|
setGroups(partition_id, groups_lists, groups_to_create, groups_to_delete)
|
||||||
|
return error_response(200, message="Groups set")
|
||||||
|
except ValueError:
|
||||||
|
return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
@ -50,442 +50,98 @@ 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_bulletins import formsemestre_bulletinetud_dict
|
||||||
|
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_formations import formation_export
|
||||||
|
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_logos import list_logos, find_logo, _list_dept_logos
|
||||||
|
from app.scodoc.sco_moduleimpl import moduleimpl_list
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/list_depts", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def list_depts():
|
|
||||||
depts = models.Departement.query.filter_by(visible=True).all()
|
|
||||||
data = [d.to_dict() for d in depts]
|
|
||||||
return jsonify(data)
|
|
||||||
|
|
||||||
|
# ###################################################### Logos ##########################################################
|
||||||
|
#
|
||||||
|
# # XXX TODO voir get_logo déjà existant dans app/views/scodoc.py
|
||||||
|
#
|
||||||
|
# @bp.route("/logos", methods=["GET"])
|
||||||
|
# def liste_logos(format="json"):
|
||||||
|
# """
|
||||||
|
# Liste des logos définis pour le site scodoc.
|
||||||
|
# """
|
||||||
|
# # fonction to use : list_logos()
|
||||||
|
# # try:
|
||||||
|
# # res = list_logos()
|
||||||
|
# # except ValueError:
|
||||||
|
# # return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
# #
|
||||||
|
# # if res is None:
|
||||||
|
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||||
|
# #
|
||||||
|
# # return res
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# @bp.route("/logos/<string:logo_name>", methods=["GET"])
|
||||||
|
# def recup_logo_global(logo_name: str):
|
||||||
|
# """
|
||||||
|
# Retourne l'image au format png ou jpg
|
||||||
|
#
|
||||||
|
# logo_name : le nom du logo rechercher
|
||||||
|
# """
|
||||||
|
# # fonction to use find_logo
|
||||||
|
# # try:
|
||||||
|
# # res = find_logo(logo_name)
|
||||||
|
# # except ValueError:
|
||||||
|
# # return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
# #
|
||||||
|
# # if res is None:
|
||||||
|
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||||
|
# #
|
||||||
|
# # return res
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# @bp.route("/departements/<string:dept>/logos", methods=["GET"])
|
||||||
|
# def logo_dept(dept: str):
|
||||||
|
# """
|
||||||
|
# Liste des logos définis pour le département visé.
|
||||||
|
#
|
||||||
|
# dept : l'id d'un département
|
||||||
|
# """
|
||||||
|
# # fonction to use: _list_dept_logos
|
||||||
|
# # dept_id = models.Departement.query.filter_by(acronym=dept).first()
|
||||||
|
# # try:
|
||||||
|
# # res = _list_dept_logos(dept_id.id)
|
||||||
|
# # except ValueError:
|
||||||
|
# # return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
# #
|
||||||
|
# # if res is None:
|
||||||
|
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||||
|
# #
|
||||||
|
# # return res
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# @bp.route("/departement/<string:dept>/logos/<string:logo_name>", methods=["GET"])
|
||||||
|
# def recup_logo_dept_global(dept: str, logo_name: str):
|
||||||
|
# """
|
||||||
|
# L'image format png ou jpg
|
||||||
|
#
|
||||||
|
# dept : l'id d'un département
|
||||||
|
# logo_name : le nom du logo rechercher
|
||||||
|
# """
|
||||||
|
# # fonction to use find_logo
|
||||||
|
# # dept_id = models.Departement.query.filter_by(acronym=dept).first()
|
||||||
|
# # try:
|
||||||
|
# # res = find_logo(logo_name, dept_id.id)
|
||||||
|
# # except ValueError:
|
||||||
|
# # return error_response(409, message="La requête ne peut être traitée en l’état actuel")
|
||||||
|
# #
|
||||||
|
# # if res is None:
|
||||||
|
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||||
|
# #
|
||||||
|
# # return res
|
||||||
|
|
||||||
@bp.route("/etudiants/courant", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def etudiants():
|
|
||||||
"""Liste de tous les étudiants actuellement inscrits à un semestre
|
|
||||||
en cours.
|
|
||||||
"""
|
|
||||||
# Vérification de l'accès: permission Observateur sur tous les départements
|
|
||||||
# (c'est un exemple à compléter)
|
|
||||||
if not g.current_user.has_permission(Permission.ScoObservateur, None):
|
|
||||||
return error_response(401, message="accès interdit")
|
|
||||||
|
|
||||||
query = db.session.query(Identite).filter(
|
|
||||||
FormSemestreInscription.formsemestre_id == FormSemestre.id,
|
|
||||||
FormSemestreInscription.etudid == Identite.id,
|
|
||||||
FormSemestre.date_debut <= func.now(),
|
|
||||||
FormSemestre.date_fin >= func.now(),
|
|
||||||
)
|
|
||||||
return jsonify([e.to_dict_bul(include_urls=False) for e in query])
|
|
||||||
|
|
||||||
|
|
||||||
######################## Departements ##################################
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departements", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def departements():
|
|
||||||
"""
|
|
||||||
Liste des ids de départements
|
|
||||||
"""
|
|
||||||
depts = models.Departement.query.filter_by(visible=True).all()
|
|
||||||
data = [d.id for d in depts]
|
|
||||||
return jsonify(data)
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departements/<string:dept>/etudiants/liste/<int:sem_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def liste_etudiants(dept, *args, sem_id): # XXX TODO A REVOIR
|
|
||||||
"""
|
|
||||||
Liste des étudiants d'un département
|
|
||||||
"""
|
|
||||||
# Test si le sem_id à été renseigné ou non
|
|
||||||
if sem_id is not None:
|
|
||||||
# Récupération du/des depts
|
|
||||||
list_depts = models.Departement.query.filter(
|
|
||||||
models.Departement.acronym == dept,
|
|
||||||
models.FormSemestre.semestre_id == sem_id,
|
|
||||||
)
|
|
||||||
list_etuds = []
|
|
||||||
for dept in list_depts:
|
|
||||||
# Récupération des étudiants d'un département
|
|
||||||
x = models.Identite.query.filter(models.Identite.dept_id == dept.getId())
|
|
||||||
for y in x:
|
|
||||||
# Ajout des étudiants dans la liste global
|
|
||||||
list_etuds.append(y)
|
|
||||||
else:
|
|
||||||
list_depts = models.Departement.query.filter(
|
|
||||||
models.Departement.acronym == dept,
|
|
||||||
models.FormSemestre.semestre_id == models.Departement.formsemestres,
|
|
||||||
)
|
|
||||||
list_etuds = []
|
|
||||||
for dept in list_depts:
|
|
||||||
x = models.Identite.query.filter(models.Identite.dept_id == dept.getId())
|
|
||||||
for y in x:
|
|
||||||
list_etuds.append(y)
|
|
||||||
|
|
||||||
data = [d.to_dict() for d in list_etuds]
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departements/<string:dept>/semestres_actifs", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def liste_semestres_actifs(dept): # TODO : changer nom
|
|
||||||
"""
|
|
||||||
Liste des semestres actifs d'un départements donné
|
|
||||||
"""
|
|
||||||
# Récupération de l'id du dept
|
|
||||||
dept_id = models.Departement.query.filter(models.Departement.acronym == dept)
|
|
||||||
# Puis ici récupération du FormSemestre correspondant
|
|
||||||
depts_actifs = models.FormSemestre.query.filter_by(
|
|
||||||
etat=True,
|
|
||||||
dept_id=dept_id,
|
|
||||||
)
|
|
||||||
data = [da.to_dict() for da in depts_actifs]
|
|
||||||
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/referentiel_competences/<int:referentiel_competence_id>")
|
|
||||||
@token_auth.login_required
|
|
||||||
def referentiel_competences(referentiel_competence_id):
|
|
||||||
"""
|
|
||||||
Le référentiel de compétences
|
|
||||||
"""
|
|
||||||
ref = ApcReferentielCompetences.query.get_or_404(referentiel_competence_id)
|
|
||||||
return jsonify(ref.to_dict())
|
|
||||||
|
|
||||||
|
|
||||||
####################### Etudiants ##################################
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/etudiant/<int:etudid>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def etudiant(etudid):
|
|
||||||
"""
|
|
||||||
Un dictionnaire avec les informations de l'étudiant correspondant à l'id passé en paramètres.
|
|
||||||
"""
|
|
||||||
etud: Identite = Identite.query.get_or_404(etudid)
|
|
||||||
return jsonify(etud.to_dict_bul())
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/etudiant/<int:etudid>/semestre/<int:sem_id>/bulletin", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def etudiant_bulletin_semestre(etudid, sem_id):
|
|
||||||
"""
|
|
||||||
Le bulletin d'un étudiant en fonction de son id et d'un semestre donné
|
|
||||||
"""
|
|
||||||
# return jsonify(models.BulAppreciations.query.filter_by(etudid=etudid, formsemestre_id=sem_id))
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:NIP>/releve",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@bp.route(
|
|
||||||
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/id/<int:etudid>/releve",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@bp.route(
|
|
||||||
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:numScodoc>/releve",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def etudiant_bulletin(formsemestre_id, dept, etudid, format="json", *args, size):
|
|
||||||
"""
|
|
||||||
Un bulletin de note
|
|
||||||
"""
|
|
||||||
formsemestres = models.FormSemestre.query.filter_by(id=formsemestre_id)
|
|
||||||
depts = models.Departement.query.filter_by(acronym=dept)
|
|
||||||
etud = ""
|
|
||||||
|
|
||||||
data = []
|
|
||||||
if args[0] == "short":
|
|
||||||
pass
|
|
||||||
elif args[0] == "selectevals":
|
|
||||||
pass
|
|
||||||
elif args[0] == "long":
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return "erreur"
|
|
||||||
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/etudiant/<int:etudid>/semestre/<int:formsemestre_id>/groups", methods=["GET"]
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def etudiant_groups(etudid: int, formsemestre_id: int):
|
|
||||||
"""
|
|
||||||
Liste des groupes auxquels appartient l'étudiant dans le semestre indiqué
|
|
||||||
"""
|
|
||||||
semestre = models.FormSemestre.query.filter_by(id=formsemestre_id)
|
|
||||||
etudiant = models.Identite.query.filter_by(id=etudid)
|
|
||||||
|
|
||||||
groups = models.Partition.query.filter(
|
|
||||||
models.Partition.formsemestre_id == semestre,
|
|
||||||
models.GroupDescr.etudiants == etudiant,
|
|
||||||
)
|
|
||||||
data = [d.to_dict() for d in groups]
|
|
||||||
# return jsonify(data)
|
|
||||||
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
#######################" Programmes de formations #########################
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formations", methods=["GET"])
|
|
||||||
@bp.route("/formations/<int:formation_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def formations(formation_id: int):
|
|
||||||
"""
|
|
||||||
Liste des formations
|
|
||||||
"""
|
|
||||||
formations = models.Formation.query.filter_by(id=formation_id)
|
|
||||||
data = [d.to_dict() for d in formations]
|
|
||||||
# return jsonify(data)
|
|
||||||
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formations/formation_export/<int:formation_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def formation_export(formation_id: int, export_ids=False):
|
|
||||||
"""
|
|
||||||
La formation, avec UE, matières, modules
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
###################### UE #######################################
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/departements/<string:dept>/formations/programme/<string:sem_id>", methods=["GET"]
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def eus(dept: str, sem_id: int):
|
|
||||||
"""
|
|
||||||
Liste des UES, ressources et SAE d'un semestre
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
######## Semestres de formation ###############
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
|
||||||
@bp.route("/formations/apo/<int:etape_apo>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def formsemestre(
|
|
||||||
id: int,
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Information sur les formsemestres
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
############ Modules de formation ##############
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
|
|
||||||
@bp.route(
|
|
||||||
"/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def moduleimpl(id: int):
|
|
||||||
"""
|
|
||||||
Liste de moduleimpl
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
########### Groupes et partitions ###############
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/partitions/<int:formsemestre_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def partition(formsemestre_id: int):
|
|
||||||
"""
|
|
||||||
La liste de toutes les partitions d'un formsemestre
|
|
||||||
"""
|
|
||||||
partitions = models.Partition.query.filter_by(id=formsemestre_id)
|
|
||||||
data = [d.to_dict() for d in partitions]
|
|
||||||
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/partitions/formsemestre/<int:formsemestre_id>/groups/group_ids?with_codes=&all_groups=&etat=",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def groups(formsemestre_id: int, group_ids: int):
|
|
||||||
"""
|
|
||||||
Liste des étudiants dans un groupe
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/partitions/set_groups?partition_id=<int:partition_id>&groups=<int:groups>&groups_to_delete=<int:groups_to_delete>&groups_to_create=<int:groups_to_create>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def set_groups(
|
|
||||||
partition_id: int, groups: int, groups_to_delete: int, groups_to_create: int
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Set les groups
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
####### Bulletins de notes ###########
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/evaluations/<int:moduleimpl_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def evaluations(moduleimpl_id: int):
|
|
||||||
"""
|
|
||||||
Liste des évaluations à partir de l'id d'un moduleimpl
|
|
||||||
"""
|
|
||||||
evals = models.Evaluation.query.filter_by(id=moduleimpl_id)
|
|
||||||
data = [d.to_dict() for d in evals]
|
|
||||||
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/evaluations/eval_notes/<int:evaluation_id>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def evaluation_notes(evaluation_id: int):
|
|
||||||
"""
|
|
||||||
Liste des notes à partir de l'id d'une évaluation donnée
|
|
||||||
"""
|
|
||||||
evals = models.Evaluation.query.filter_by(id=evaluation_id)
|
|
||||||
notes = evals.get_notes()
|
|
||||||
|
|
||||||
data = [d.to_dict() for d in notes]
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<int:note>",
|
|
||||||
methods=["POST"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def evaluation_set_notes(eval_id: int, etudid: int, note: float):
|
|
||||||
"""
|
|
||||||
Set les notes d'une évaluation pour un étudiant donnée
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
############## Absences #############
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/<int:etudid>", methods=["GET"])
|
|
||||||
@bp.route("/absences/<int:etudid>/abs_just_only", methods=["GET"])
|
|
||||||
def absences(etudid: int):
|
|
||||||
"""
|
|
||||||
Liste des absences d'un étudiant donnée
|
|
||||||
"""
|
|
||||||
abs = models.Absence.query.filter_by(id=etudid)
|
|
||||||
|
|
||||||
data = [d.to_dict() for d in abs]
|
|
||||||
|
|
||||||
# return jsonify(data)
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/abs_signale", methods=["POST"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def abs_signale():
|
|
||||||
"""
|
|
||||||
Retourne un html
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/abs_annule", methods=["POST"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def abs_annule():
|
|
||||||
"""
|
|
||||||
Retourne un html
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/abs_annule_justif", methods=["POST"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def abs_annule_justif():
|
|
||||||
"""
|
|
||||||
Retourne un html
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/absences/abs_group_etat/?group_ids=<int:group_ids>&date_debut=date_debut&date_fin=date_fin",
|
|
||||||
methods=["GET"],
|
|
||||||
)
|
|
||||||
@token_auth.login_required
|
|
||||||
def abs_groupe_etat(
|
|
||||||
group_ids: int, date_debut, date_fin, with_boursier=True, format="html"
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Liste des absences d'un ou plusieurs groupes entre deux dates
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
################ Logos ################
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/logos", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def liste_logos(format="json"):
|
|
||||||
"""
|
|
||||||
Liste des logos définis pour le site scodoc.
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/logos/<string:nom>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def recup_logo_global(nom: str):
|
|
||||||
"""
|
|
||||||
Retourne l'image au format png ou jpg
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departements/<string:dept>/logos", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def logo_dept(dept: str):
|
|
||||||
"""
|
|
||||||
Liste des logos définis pour le département visé.
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/departement/<string:dept>/logos/<string:nom>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
|
||||||
def recup_logo_dept_global(dept: str, nom: str):
|
|
||||||
"""
|
|
||||||
L'image format png ou jpg
|
|
||||||
"""
|
|
||||||
return error_response(501, message="Not implemented")
|
|
||||||
|
493
app/api/test_api.py
Normal file
493
app/api/test_api.py
Normal file
@ -0,0 +1,493 @@
|
|||||||
|
################################################## Tests ##############################################################
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app import models
|
||||||
|
from app.api import bp, requested_format
|
||||||
|
from app.api.auth import token_auth
|
||||||
|
from app.api.errors import error_response
|
||||||
|
|
||||||
|
SCODOC_USER = "test"
|
||||||
|
SCODOC_PASSWORD = "test"
|
||||||
|
SCODOC_URL = "http://192.168.1.12:5000"
|
||||||
|
CHECK_CERTIFICATE = bool(int(os.environ.get("CHECK_CERTIFICATE", False)))
|
||||||
|
|
||||||
|
HEADERS = None
|
||||||
|
|
||||||
|
def get_token():
|
||||||
|
"""
|
||||||
|
Permet de set le token dans le header
|
||||||
|
"""
|
||||||
|
global HEADERS
|
||||||
|
global SCODOC_USER
|
||||||
|
global SCODOC_PASSWORD
|
||||||
|
|
||||||
|
r0 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/tokens", auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
token = r0.json()["token"]
|
||||||
|
HEADERS = {"Authorization": f"Bearer {token}"}
|
||||||
|
|
||||||
|
|
||||||
|
DEPT = None
|
||||||
|
FORMSEMESTRE = None
|
||||||
|
ETU = None
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_dept", methods=["GET"])
|
||||||
|
def get_departement():
|
||||||
|
"""
|
||||||
|
Permet de tester departements() mais également de set un département dans DEPT pour la suite des tests
|
||||||
|
"""
|
||||||
|
|
||||||
|
get_token()
|
||||||
|
|
||||||
|
global HEADERS
|
||||||
|
global CHECK_CERTIFICATE
|
||||||
|
global SCODOC_USER
|
||||||
|
global SCODOC_PASSWORD
|
||||||
|
|
||||||
|
# print(HEADERS)
|
||||||
|
# departements
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE,
|
||||||
|
)
|
||||||
|
|
||||||
|
if r.status_code == 200:
|
||||||
|
dept_id = r.json()[0]
|
||||||
|
# print(dept_id)
|
||||||
|
|
||||||
|
dept = models.Departement.query.filter_by(id=dept_id).first()
|
||||||
|
dept = dept.to_dict()
|
||||||
|
|
||||||
|
fields = ["id", "acronym", "description", "visible", "date_creation"]
|
||||||
|
|
||||||
|
for field in dept:
|
||||||
|
if field not in fields:
|
||||||
|
return error_response(501, field + " field missing")
|
||||||
|
|
||||||
|
global DEPT
|
||||||
|
DEPT = dept
|
||||||
|
|
||||||
|
return error_response(200, "OK")
|
||||||
|
|
||||||
|
return error_response(409, "La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_formsemestre", methods=["GET"])
|
||||||
|
def get_formsemestre():
|
||||||
|
"""
|
||||||
|
Permet de tester liste_semestres_courant() mais également de set un formsemestre dans FORMSEMESTRE
|
||||||
|
pour la suite des tests
|
||||||
|
"""
|
||||||
|
get_departement()
|
||||||
|
|
||||||
|
global DEPT
|
||||||
|
dept_acronym = DEPT["acronym"]
|
||||||
|
|
||||||
|
# liste_semestres_courant
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/" + dept_acronym + "/semestres_courants",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
if r.status_code == 200:
|
||||||
|
formsemestre = r.json()[0]
|
||||||
|
print(r.json()[0])
|
||||||
|
|
||||||
|
fields = ["gestion_semestrielle", "titre", "scodoc7_id", "date_debut", "bul_bgcolor", "date_fin",
|
||||||
|
"resp_can_edit", "dept_id", "etat", "resp_can_change_ens", "id", "modalite", "ens_can_edit_eval",
|
||||||
|
"formation_id", "gestion_compensation", "elt_sem_apo", "semestre_id", "bul_hide_xml", "elt_annee_apo",
|
||||||
|
"block_moyennes", "formsemestre_id", "titre_num", "date_debut_iso", "date_fin_iso", "responsables"]
|
||||||
|
|
||||||
|
for field in formsemestre:
|
||||||
|
if field not in fields:
|
||||||
|
return error_response(501, field + " field missing")
|
||||||
|
|
||||||
|
global FORMSEMESTRE
|
||||||
|
FORMSEMESTRE = formsemestre
|
||||||
|
|
||||||
|
return error_response(200, "OK")
|
||||||
|
|
||||||
|
return error_response(409, "La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_etu", methods=["GET"])
|
||||||
|
def get_etudiant():
|
||||||
|
"""
|
||||||
|
Permet de tester etudiants() mais également de set un etudiant dans ETU pour la suite des tests
|
||||||
|
"""
|
||||||
|
|
||||||
|
# etudiants
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
if r.status_code == 200:
|
||||||
|
etu = r.json()[0]
|
||||||
|
|
||||||
|
fields = ["civilite", "code_ine", "code_nip", "date_naissance", "email", "emailperso", "etudid", "nom",
|
||||||
|
"prenom"]
|
||||||
|
|
||||||
|
for field in etu:
|
||||||
|
if field not in fields:
|
||||||
|
return error_response(501, field + " field missing")
|
||||||
|
|
||||||
|
global ETU
|
||||||
|
ETU = etu
|
||||||
|
print(etu)
|
||||||
|
|
||||||
|
return error_response(200, "OK")
|
||||||
|
|
||||||
|
return error_response(409, "La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
|
||||||
|
############################################### Departements ##########################################################
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_liste_etudiants")
|
||||||
|
def test_departements_liste_etudiants():
|
||||||
|
"""
|
||||||
|
Test la route liste_etudiants
|
||||||
|
"""
|
||||||
|
# Set un département et un formsemestre pour les tests
|
||||||
|
get_departement()
|
||||||
|
get_formsemestre()
|
||||||
|
|
||||||
|
global DEPT
|
||||||
|
global FORMSEMESTRE
|
||||||
|
|
||||||
|
# Set les fields à vérifier
|
||||||
|
fields = ["civilite", "code_ine", "code_nip", "date_naissance", "email", "emailperso", "etudid", "nom", "prenom"]
|
||||||
|
|
||||||
|
# liste_etudiants (sans formsemestre)
|
||||||
|
r1 = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/" + DEPT["acronym"] + "/etudiants/liste",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
if r1.status_code == 200: # Si la requête est "OK"
|
||||||
|
# On récupère la liste des étudiants
|
||||||
|
etudiants = r1.json()
|
||||||
|
|
||||||
|
# Vérification que tous les étudiants ont bien tous les bons champs
|
||||||
|
for etu in etudiants:
|
||||||
|
for field in etu:
|
||||||
|
if field not in fields:
|
||||||
|
return error_response(501, field + " field missing")
|
||||||
|
|
||||||
|
|
||||||
|
# liste_etudiants (avec formsemestre)
|
||||||
|
r2 = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/" + DEPT["acronym"] + "/etudiants/liste/" +
|
||||||
|
str(FORMSEMESTRE["formsemestre_id"]),
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
if r2.status_code == 200: # Si la requête est "OK"
|
||||||
|
# On récupère la liste des étudiants
|
||||||
|
etudiants = r2.json()
|
||||||
|
|
||||||
|
# Vérification que tous les étudiants ont bien tous les bons champs
|
||||||
|
for etu in etudiants:
|
||||||
|
for field in etu:
|
||||||
|
if field not in fields:
|
||||||
|
return error_response(501, field + " field missing")
|
||||||
|
|
||||||
|
return error_response(200, "OK")
|
||||||
|
|
||||||
|
return error_response(409, "La requête ne peut être traitée en l’état actuel")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_referenciel_competences")
|
||||||
|
def test_departements_referenciel_competences():
|
||||||
|
"""
|
||||||
|
Test la route referenciel_competences
|
||||||
|
"""
|
||||||
|
get_departement()
|
||||||
|
get_formsemestre()
|
||||||
|
|
||||||
|
global DEPT
|
||||||
|
global FORMSEMESTRE
|
||||||
|
|
||||||
|
# referenciel_competences
|
||||||
|
r = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/" + DEPT["acronym"] + "/formations/" +
|
||||||
|
FORMSEMESTRE["formation_id"] + "/referentiel_competences",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/test_liste_semestre_index")
|
||||||
|
def test_departements_semestre_index():
|
||||||
|
"""
|
||||||
|
Test la route semestre_index
|
||||||
|
"""
|
||||||
|
# semestre_index
|
||||||
|
r5 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/" + DEPT["acronym"] + "/formsemestre/" +
|
||||||
|
FORMSEMESTRE["formation_id"] + "/programme",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#################################################### Etudiants ########################################################
|
||||||
|
|
||||||
|
def test_routes_etudiants():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Etudiants
|
||||||
|
"""
|
||||||
|
# etudiants
|
||||||
|
r1 = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiants",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiants_courant
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiant
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiant_formsemestres
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiant_bulletin_semestre
|
||||||
|
r5 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiant_groups
|
||||||
|
r6 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_formation():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Formation
|
||||||
|
"""
|
||||||
|
# formations
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# formations_by_id
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# formation_export_by_formation_id
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# formsemestre_apo
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# moduleimpls
|
||||||
|
r5 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# moduleimpls_sem
|
||||||
|
r6 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_formsemestres():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Formsemestres
|
||||||
|
"""
|
||||||
|
# formsemestre
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etudiant_bulletin
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# bulletins
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# jury
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_partitions():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Partitions
|
||||||
|
"""
|
||||||
|
# partition
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# etud_in_group
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# set_groups
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_evaluations():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Evaluations
|
||||||
|
"""
|
||||||
|
# evaluations
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# evaluation_notes
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# evaluation_set_notes
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_jury():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Jury
|
||||||
|
"""
|
||||||
|
# jury_preparation
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# jury_decisions
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# set_decision_jury
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# annule_decision_jury
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_absences():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Absences
|
||||||
|
"""
|
||||||
|
# absences
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# absences_justify
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# abs_signale
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# abs_annule
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# abs_annule_justif
|
||||||
|
r5 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# abs_groupe_etat
|
||||||
|
r6 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_routes_logos():
|
||||||
|
"""
|
||||||
|
Test les routes de la partie Logos
|
||||||
|
"""
|
||||||
|
# liste_logos
|
||||||
|
r1 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# recup_logo_global
|
||||||
|
r2 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# logo_dept
|
||||||
|
r3 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
|
||||||
|
# recup_logo_dept_global
|
||||||
|
r4 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api",
|
||||||
|
auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
@ -47,6 +47,11 @@ _SCO_PERMISSIONS = (
|
|||||||
),
|
),
|
||||||
(1 << 25, "RelationsEntreprisesSend", "Envoyer des offres"),
|
(1 << 25, "RelationsEntreprisesSend", "Envoyer des offres"),
|
||||||
(1 << 26, "RelationsEntreprisesValidate", "Valide les entreprises"),
|
(1 << 26, "RelationsEntreprisesValidate", "Valide les entreprises"),
|
||||||
|
# Api scodoc9
|
||||||
|
(1 << 27, "APIView", "Voir"),
|
||||||
|
(1 << 28, "APIEtudChangeGroups", "Modifier les groupes"),
|
||||||
|
(1 << 29, "APIEditAllNotes", "Modifier toutes les notes"),
|
||||||
|
(1 << 30, "APIAbsChange", "Saisir des absences"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ SCO_ROLES_DEFAULTS = {
|
|||||||
p.ScoUsersAdmin,
|
p.ScoUsersAdmin,
|
||||||
p.ScoUsersView,
|
p.ScoUsersView,
|
||||||
p.ScoView,
|
p.ScoView,
|
||||||
|
p.APIView,
|
||||||
),
|
),
|
||||||
# RespPE est le responsable poursuites d'études
|
# RespPE est le responsable poursuites d'études
|
||||||
# il peut ajouter des tags sur les formations:
|
# il peut ajouter des tags sur les formations:
|
||||||
|
40
tests/api/setup_test_api.py
Normal file
40
tests/api/setup_test_api.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
SCODOC_USER = "test"
|
||||||
|
SCODOC_PASSWORD = "test"
|
||||||
|
SCODOC_URL = "http://192.168.1.12:5000"
|
||||||
|
CHECK_CERTIFICATE = bool(int(os.environ.get("CHECK_CERTIFICATE", False)))
|
||||||
|
|
||||||
|
HEADERS = None
|
||||||
|
|
||||||
|
def get_token():
|
||||||
|
"""
|
||||||
|
Permet de set le token dans le header
|
||||||
|
"""
|
||||||
|
global HEADERS
|
||||||
|
global SCODOC_USER
|
||||||
|
global SCODOC_PASSWORD
|
||||||
|
|
||||||
|
r0 = requests.post(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/tokens", auth=(SCODOC_USER, SCODOC_PASSWORD)
|
||||||
|
)
|
||||||
|
token = r0.json()["token"]
|
||||||
|
HEADERS = {"Authorization": f"Bearer {token}"}
|
||||||
|
|
||||||
|
get_token()
|
143
tests/api/test_api_absences.py
Normal file
143
tests/api/test_api_absences.py
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_absences.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# absences
|
||||||
|
def test_absences():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/<int:etudid>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/nip/<int:nip>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/ine/<int:ine>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# absences_justify
|
||||||
|
def test_absences_justify():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/etudid/<int:etudid>/abs_just_only",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/nip/<int:nip>/abs_just_only",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/ine/<int:ine>/abs_just_only",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# abs_signale
|
||||||
|
def test_abs_signale():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_signale?etudid=<int:etudid>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
"&description=<string:description>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_signale?nip=<int:nip>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
"&description=<string:description>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
"&description=<string:description>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||||
|
"&description=<string:description>&moduleimpl_id=<int:moduleimpl_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# abs_annule
|
||||||
|
def test_abs_annule():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# abs_annule_justif
|
||||||
|
def test_abs_annule_justif():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule_justif?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule_justif?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_annule_justif?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# abs_groupe_etat
|
||||||
|
def test_abs_groupe_etat():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
94
tests/api/test_api_departements.py
Normal file
94
tests/api/test_api_departements.py
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_departements.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# departements
|
||||||
|
def test_departements():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
# liste_etudiants
|
||||||
|
def test_liste_etudiants():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 16
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 16
|
||||||
|
|
||||||
|
|
||||||
|
# liste_semestres_courant
|
||||||
|
def test_semestres_courant():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
# referenciel_competences
|
||||||
|
def test_referenciel_competences():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200 or 204
|
||||||
|
|
||||||
|
|
||||||
|
# # semestre_index
|
||||||
|
# def test_semestre_index():
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
146
tests/api/test_api_etudiants.py
Normal file
146
tests/api/test_api_etudiants.py
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_etudiants.py
|
||||||
|
"""
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# etudiants
|
||||||
|
def test_etudiants():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiants",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 16
|
||||||
|
|
||||||
|
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
||||||
|
etu = r.json()[randint(0, len(r.json()))-1]
|
||||||
|
|
||||||
|
fields = ["civilite", "code_ine", "code_nip", "date_naissance", "email", "emailperso", "etudid", "nom",
|
||||||
|
"prenom", "nomprenom"]
|
||||||
|
|
||||||
|
fields_OK = True
|
||||||
|
|
||||||
|
# Vérifie si tous les champs sont bien présents
|
||||||
|
for field in etu:
|
||||||
|
if field not in fields:
|
||||||
|
fields_OK = False
|
||||||
|
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
|
# etudiants_courant
|
||||||
|
def test_etudiants_courant():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 0
|
||||||
|
|
||||||
|
|
||||||
|
# etudiant
|
||||||
|
def test_etudiant():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 10
|
||||||
|
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# etudiant_formsemestres
|
||||||
|
def test_etudiant_formsemestres():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestres",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 1
|
||||||
|
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestres",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
#
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/formsemestres",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# etudiant_bulletin_semestre
|
||||||
|
# def test_etudiant_bulletin_semestre():
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
# assert len(r.json()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
#
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# etudiant_groups
|
||||||
|
def test_etudiant_groups():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/semestre/1/groups",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert len(r.json()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/semestre/<int:formsemestre_id>/groups",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
||||||
|
#
|
||||||
|
# r = requests.get(
|
||||||
|
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/semestre/<int:formsemestre_id>/groups",
|
||||||
|
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
# )
|
||||||
|
# assert r.status_code == 200
|
58
tests/api/test_api_evaluations.py
Normal file
58
tests/api/test_api_evaluations.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_evaluations.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# evaluations
|
||||||
|
def test_evaluations():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/evaluations/<int:moduleimpl_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# evaluation_notes
|
||||||
|
def test_evaluation_notes():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/evaluations/eval_notes/<int:evaluation_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# evaluation_set_notes
|
||||||
|
def test_evaluation_set_notes():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<float:note>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/evaluations/eval_set_notes?eval_id=<int:eval_id>&nip=<int:nip>¬e=<float:note>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/evaluations/eval_set_notes?eval_id=<int:eval_id>&ine=<int:ine>¬e=<float:note>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
72
tests/api/test_api_formations.py
Normal file
72
tests/api/test_api_formations.py
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_formations.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# formations
|
||||||
|
def test_formations():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# formations_by_id
|
||||||
|
def test_formations_by_id():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/<int:formation_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# formation_export_by_formation_id
|
||||||
|
def test_formation_export_by_formation_id():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/formation_export/<int:formation_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# formsemestre_apo
|
||||||
|
def test_formsemestre_apo():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# moduleimpls
|
||||||
|
def test_moduleimpls():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/<int:moduleimpl_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# moduleimpls_sem
|
||||||
|
def test_moduleimpls_sem():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
67
tests/api/test_api_formsemestre_.py
Normal file
67
tests/api/test_api_formsemestre_.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_formsemestre.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# formsemestre
|
||||||
|
def test_formsemestre():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formations/formsemestre/<int:formsemestre_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# etudiant_bulletin
|
||||||
|
def test_etudiant_bulletin():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# bulletins
|
||||||
|
def test_bulletins():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/bulletins",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# jury
|
||||||
|
def test_jury():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/formsemestre/<int:formsemestre_id>/jury",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
83
tests/api/test_api_jury.py
Normal file
83
tests/api/test_api_jury.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_jury.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# jury_preparation
|
||||||
|
def test_jury_preparation():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/formsemestre/<int:formsemestre_id>/preparation_jury",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# jury_decisions
|
||||||
|
def test_jury_decisions():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/formsemestre/<int:formsemestre_id>/decisions_jury",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# set_decision_jury
|
||||||
|
def test_set_decision_jury():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/set_decision/etudid?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/set_decision/nip?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/set_decision/ine?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
|
||||||
|
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# annule_decision_jury
|
||||||
|
def test_annule_decision_jury():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/annule_decision",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/nip/<int:nip>/formsemestre/<int:formsemestre_id>/annule_decision",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/jury/ine/<int:ine>/formsemestre/<int:formsemestre_id>/annule_decision",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
53
tests/api/test_api_partitions.py
Normal file
53
tests/api/test_api_partitions.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Test Logos
|
||||||
|
|
||||||
|
Utilisation :
|
||||||
|
créer les variables d'environnement: (indiquer les valeurs
|
||||||
|
pour le serveur ScoDoc que vous voulez interroger)
|
||||||
|
|
||||||
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
||||||
|
export SCODOC_USER="xxx"
|
||||||
|
export SCODOC_PASSWD="xxx"
|
||||||
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
||||||
|
|
||||||
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
||||||
|
|
||||||
|
Lancer :
|
||||||
|
pytest tests/api/test_api_partitions.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||||
|
|
||||||
|
|
||||||
|
# partition
|
||||||
|
def test_partition():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/partitions/<int:formsemestre_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# etud_in_group
|
||||||
|
def test_etud_in_group():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/partitions/groups/<int:group_id>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/partitions/groups/<int:group_id>/etat/<string:etat>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
# set_groups
|
||||||
|
def test_set_groups():
|
||||||
|
r = requests.get(
|
||||||
|
SCODOC_URL + "/ScoDoc/api/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&"
|
||||||
|
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>",
|
||||||
|
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
@ -13,6 +13,7 @@
|
|||||||
flask db upgrade
|
flask db upgrade
|
||||||
flask sco-db-init --erase
|
flask sco-db-init --erase
|
||||||
flask init-test-database
|
flask init-test-database
|
||||||
|
flask user-role -a Admin -d TAPI test
|
||||||
|
|
||||||
3) relancer ScoDoc:
|
3) relancer ScoDoc:
|
||||||
flask run --host 0.0.0.0
|
flask run --host 0.0.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user