routes les plus basiques fonctionnel
This commit is contained in:
parent
fa5536ce2c
commit
e8d12261c9
|
@ -51,54 +51,20 @@ from app import models
|
|||
from app.models import FormSemestre, FormSemestreInscription, Identite
|
||||
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)
|
||||
return error_response(501, message="Not implemented")
|
||||
|
||||
|
||||
@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 Observateir 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])
|
||||
return error_response(501, message="Not implemented")
|
||||
|
||||
|
||||
######################## Departements ##################################
|
||||
|
||||
|
||||
@bp.route("/departements", methods=["GET"])
|
||||
@token_auth.login_required
|
||||
def departements():
|
||||
"""
|
||||
Liste des id de départements
|
||||
"""
|
||||
depts = models.Departement.query.filter_by(visible=True).all()
|
||||
data = [d.to_dict() for d in depts]
|
||||
# return jsonify(data)
|
||||
return error_response(501, message="Not implemented")
|
||||
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):
|
||||
"""
|
||||
Liste des étudiants d'un département
|
||||
|
@ -134,7 +100,6 @@ def liste_etudiants(dept, *args, sem_id):
|
|||
|
||||
|
||||
@bp.route("/departements/<string:dept>/semestres_actifs", methods=["GET"])
|
||||
@token_auth.login_required
|
||||
def liste_semestres_actifs(dept):
|
||||
"""
|
||||
Liste des semestres actifs d'un départements donné
|
||||
|
@ -153,9 +118,9 @@ def liste_semestres_actifs(dept):
|
|||
|
||||
|
||||
@bp.route(
|
||||
"/departements/<string:dept>/formations/<int:formation>/referentiel_competences"
|
||||
"/departements/<string:dept>/formations/<int:formation>/referentiel_competences",
|
||||
methods=["GET"],
|
||||
)
|
||||
@token_auth.login_required
|
||||
def referenciel_competences(dept, formation):
|
||||
"""
|
||||
Le référenciel de compétences d'une formation donnée
|
||||
|
@ -174,17 +139,18 @@ def referenciel_competences(dept, formation):
|
|||
|
||||
|
||||
@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.
|
||||
"""
|
||||
# return jsonify(models.Identite.query.filter_by(etudid=etudid))
|
||||
return error_response(501, message="Not implemented")
|
||||
etu = models.Identite.query.filter_by(id=etudid).all()
|
||||
data = etu[0].to_dict()
|
||||
|
||||
return jsonify(data)
|
||||
# return error_response(501, message="Not implemented")
|
||||
|
||||
|
||||
@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é
|
||||
|
@ -205,7 +171,6 @@ def etudiant_bulletin_semestre(etudid, sem_id):
|
|||
"/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
|
||||
|
@ -231,12 +196,11 @@ def etudiant_bulletin(formsemestre_id, dept, etudid, format="json", *args, size)
|
|||
@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)
|
||||
semestre = models.FormSemestre.query.filter_by(id=formsemestre_id).all()
|
||||
etudiant = models.Identite.query.filter_by(id=etudid)
|
||||
|
||||
groups = models.Partition.query.filter(
|
||||
|
@ -253,21 +217,32 @@ def etudiant_groups(etudid: int, formsemestre_id: int):
|
|||
|
||||
|
||||
@bp.route("/formations", methods=["GET"])
|
||||
@bp.route("/formations/<int:formation_id>", methods=["GET"])
|
||||
@token_auth.login_required
|
||||
def formations(formation_id: int):
|
||||
def formations():
|
||||
"""
|
||||
Liste des formations
|
||||
"""
|
||||
formations = models.Formation.query.filter_by(id=formation_id)
|
||||
data = [d.to_dict() for d in formations]
|
||||
# return jsonify(data)
|
||||
list_formations = models.Formation.query.all()
|
||||
|
||||
return error_response(501, message="Not implemented")
|
||||
data = [d.to_dict() for d in list_formations]
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@bp.route("/formations/<int:formation_id>", methods=["GET"])
|
||||
def formations_by_id(formation_id: int):
|
||||
"""
|
||||
Formation en fonction d'un id donné
|
||||
"""
|
||||
forma = models.Formation.query.filter_by(id=formation_id).all()
|
||||
|
||||
data = [d.to_dict() for d in forma]
|
||||
|
||||
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
|
||||
|
@ -281,7 +256,6 @@ def formation_export(formation_id: int, export_ids=False):
|
|||
@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
|
||||
|
@ -293,11 +267,19 @@ def eus(dept: str, sem_id: int):
|
|||
|
||||
|
||||
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
||||
def formsemestre(formsemestre_id: int):
|
||||
"""
|
||||
Information sur le formsemestre correspondant au formsemestre_id
|
||||
"""
|
||||
list_formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id)
|
||||
|
||||
data = list_formsemetre[0].to_dict()
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@bp.route("/formations/apo/<int:etape_apo>", methods=["GET"])
|
||||
@token_auth.login_required
|
||||
def formsemestre(
|
||||
id: int,
|
||||
):
|
||||
def formsemestre_apo(etape_apo: int):
|
||||
"""
|
||||
Information sur les formsemestres
|
||||
"""
|
||||
|
@ -308,11 +290,21 @@ def formsemestre(
|
|||
|
||||
|
||||
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
|
||||
def moduleimpls(moduleimpl_id: int):
|
||||
"""
|
||||
Liste des moduleimpl
|
||||
"""
|
||||
list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id)
|
||||
|
||||
data = list_moduleimpls[0].to_dict()
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>",
|
||||
methods=["GET"],
|
||||
)
|
||||
@token_auth.login_required
|
||||
def moduleimpl(id: int):
|
||||
"""
|
||||
Liste de moduleimpl
|
||||
|
@ -324,7 +316,6 @@ def moduleimpl(id: int):
|
|||
|
||||
|
||||
@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
|
||||
|
@ -340,7 +331,6 @@ def partition(formsemestre_id: int):
|
|||
"/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
|
||||
|
@ -366,7 +356,6 @@ def set_groups(
|
|||
|
||||
|
||||
@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
|
||||
|
@ -379,7 +368,6 @@ def evaluations(moduleimpl_id: int):
|
|||
|
||||
|
||||
@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
|
||||
|
@ -452,7 +440,6 @@ def abs_annule_justif():
|
|||
"/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"
|
||||
):
|
||||
|
@ -466,7 +453,6 @@ def abs_groupe_etat(
|
|||
|
||||
|
||||
@bp.route("/logos", methods=["GET"])
|
||||
@token_auth.login_required
|
||||
def liste_logos(format="json"):
|
||||
"""
|
||||
Liste des logos définis pour le site scodoc.
|
||||
|
@ -475,7 +461,6 @@ def liste_logos(format="json"):
|
|||
|
||||
|
||||
@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
|
||||
|
@ -484,7 +469,6 @@ def recup_logo_global(nom: str):
|
|||
|
||||
|
||||
@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é.
|
||||
|
@ -493,7 +477,6 @@ def logo_dept(dept: str):
|
|||
|
||||
|
||||
@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
|
||||
|
|
|
@ -69,6 +69,14 @@ class Identite(db.Model):
|
|||
"le mail associé à la première adrese de l'étudiant, ou None"
|
||||
return self.adresses[0].email or None if self.adresses.count() > 0 else None
|
||||
|
||||
def to_dict(self):
|
||||
data = {
|
||||
"id": self.id,
|
||||
"nom": self.nom,
|
||||
"prenom": self.prenom,
|
||||
}
|
||||
return data
|
||||
|
||||
def to_dict_bul(self, include_urls=True):
|
||||
"""Infos exportées dans les bulletins"""
|
||||
from app.scodoc import sco_photos
|
||||
|
|
Loading…
Reference in New Issue