diff --git a/app/api/sco_api.py b/app/api/sco_api.py index 6aa488c2..d824132b 100644 --- a/app/api/sco_api.py +++ b/app/api/sco_api.py @@ -52,7 +52,7 @@ from app.models import FormSemestre, FormSemestreInscription, Identite from app.scodoc.sco_permissions import Permission -@bp.route("list_depts", methods=["GET"]) +@bp.route("/list_depts", methods=["GET"]) @token_auth.login_required def list_depts(): depts = models.Departement.query.filter_by(visible=True).all() @@ -78,3 +78,167 @@ def etudiants(): 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 id de départements + """ + depts = models.Departement.query.filter_by(visible=True).all() + data = [d.to_dict() for d in depts] + return jsonify(data) + + +@bp.route("/departements//etudiants/liste/", methods=["GET"]) +@token_auth.login_required +def liste_etudiants(dept, *args, sem_id): + """ + Liste des étudiants d'un département + """ + if sem_id is not None: + list_etu = models.Departement.query.filter( + models.Departement.acronym == dept, + models.FormSemestre.semestre_id == sem_id, + ) + else: + list_etu = models.Departement.query.filter( + models.Departement.acronym == dept, + models.FormSemestre.semestre_id == models.Departement.formsemestres, + ) + data = [d.to_dict() for d in list_etu] + return jsonify(data) + + +@bp.route("/departements//semestres_actifs", methods=["GET"]) +@token_auth.login_required +def liste_semestres_actifs(dept): + """ + Liste des semestres actifs d'un départements donné + """ + dept_id = models.Departement.query.filter(models.Departement.acronym == dept) + 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) + + +@bp.route("/departements//formations//referentiel_competences") +@token_auth.login_required +def referenciel_competences(dept, formation): + """ + Le référenciel de compétences d'une formation donnée + """ + ref_comp = models.Formation.query.filter( + models.Departement.acronym == dept, + models.Formation.referentiel_competence_id == formation, + ) + data = [rc.to_dict() for rc in ref_comp] + + return jsonify(data) + + +####################### Etudiants ################################## + +@bp.route("/etudiant/", 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)) + + +@bp.route("/etudiant//semestre//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)) + + +@bp.route("/formsemestre//departements//etudiant/nip//releve") +@bp.route("/formsemestre//departements//etudiant/id//releve") +@bp.route("/formsemestre//departements//etudiant/ine//semestre//groups") +@token_auth.login_required +def etudiant_groups(etudid : int, fromsemestre_id : int): + """ + Liste des groupes auxquels appartient l'étudiant dans le semestre indiqué + """ + pass + +#######################" Programmes de formations ######################### + +@bp.route("/formations") +@bp.route("/formations/") +@token_auth.login_required +def formation_export(formation_id : int, export_ids=False): + """ + La formation, avec UE, matières, modules + """ + pass + +###################### UE ####################################### + +@bp.route("/departements//formations/programme/string:sem_id>") +@token_auth.login_required +def eus(dept : str, sem_id : int): + """ + Liste des UES, ressources et SAE d'un semestre + """ + pass + + +######## Semestres de formation ############### + + + + +############ Modules de formation ############## + + +########### Groupes et partitions ############### + + +####### Bulletins de notes ########### + + +############## Absences ############# + + +################ Logos ################