forked from ScoDoc/ScoDoc
ajout des nouvelles routes pour récupérer la liste des étudiants d'un semestre
This commit is contained in:
parent
4250d33cf5
commit
9905286168
@ -7,6 +7,7 @@ from app.api import bp
|
||||
from app.api.auth import token_auth, token_permission_required
|
||||
from app.models import Departement, FormSemestre, FormSemestreEtape
|
||||
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
|
||||
from app.scodoc.sco_groups import get_etud_groups
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
|
||||
@ -412,3 +413,50 @@ def formsemestre_programme(formsemestre_id: int):
|
||||
"modules": m_list[ModuleType.STANDARD],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/etudiants/inscrits",
|
||||
methods=["GET"],
|
||||
defaults={"etat": "I"},
|
||||
)
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
|
||||
methods=["GET"],
|
||||
defaults={"etat": "D"},
|
||||
)
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
|
||||
methods=["GET"],
|
||||
defaults={"etat": "DEF"},
|
||||
)
|
||||
@token_auth.login_required
|
||||
@token_permission_required(Permission.APIView)
|
||||
def formsemestre_etudiants(formsemestre_id: int, etat: str):
|
||||
"""
|
||||
Retourne la liste des étudiants d'un semestre
|
||||
|
||||
formsemestre_id : l'id d'un semestre
|
||||
"""
|
||||
# fonction to use : sco_groups.get_etud_groups
|
||||
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
|
||||
# Récupération des étudiants du formsemestre
|
||||
etuds = [etu.to_dict_short() for etu in formsemestre.etuds]
|
||||
|
||||
res = []
|
||||
# Trie des étudiants suivant leur état d'inscription voulu
|
||||
for etu in etuds:
|
||||
formsemestre_inscription = models.FormSemestreInscription.query.filter_by(
|
||||
formsemestre_id=formsemestre_id, etudid=etu["id"]
|
||||
).first_or_404()
|
||||
if formsemestre_inscription.etat == etat:
|
||||
res.append(etu)
|
||||
# Ajout des groups de chaques étudiants
|
||||
for etu in res:
|
||||
etu["groups"] = get_etud_groups(etu["id"], formsemestre_id)
|
||||
|
||||
return jsonify(res)
|
||||
|
@ -101,7 +101,7 @@ def test_etudiant(api_headers):
|
||||
)
|
||||
assert r.status_code == 200
|
||||
etud = r.json()
|
||||
assert len(etud) == 25
|
||||
assert len(etud) == 26
|
||||
fields_ok = verify_fields(etud, ETUD_FIELDS)
|
||||
assert fields_ok is True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user