forked from ScoDoc/ScoDoc
API: /etudiants/courant/long et /etudiants/courant
This commit is contained in:
parent
86ef24586d
commit
07cdd29716
@ -12,12 +12,12 @@ from app.models import FormSemestreInscription, FormSemestre, Identite
|
|||||||
from app.scodoc import sco_bulletins
|
from app.scodoc import sco_bulletins
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
from app.scodoc import notesdb as ndb
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/etudiants/courant", methods=["GET"])
|
@bp.route("/etudiants/courant", defaults={"long": False})
|
||||||
|
@bp.route("/etudiants/courant/long", defaults={"long": True})
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def etudiants_courant():
|
def etudiants_courant(long=False):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des étudiants courant
|
Retourne la liste des étudiants courant
|
||||||
|
|
||||||
@ -55,8 +55,10 @@ def etudiants_courant():
|
|||||||
FormSemestre.date_debut <= app.db.func.now(),
|
FormSemestre.date_debut <= app.db.func.now(),
|
||||||
FormSemestre.date_fin >= app.db.func.now(),
|
FormSemestre.date_fin >= app.db.func.now(),
|
||||||
)
|
)
|
||||||
|
if long:
|
||||||
data = [etu.to_dict_bul(include_urls=False) for etu in etuds]
|
data = [etud.to_dict_bul(include_urls=False) for etud in etuds]
|
||||||
|
else:
|
||||||
|
data = [etud.to_dict_short() for etud in etuds]
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
@ -141,7 +141,18 @@ class Identite(db.Model):
|
|||||||
"Le mail associé à la première adrese de l'étudiant, ou None"
|
"Le mail associé à la première adrese de l'étudiant, ou None"
|
||||||
return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None
|
return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None
|
||||||
|
|
||||||
def to_dict_scodoc7(self):
|
def to_dict_short(self) -> dict:
|
||||||
|
"""Les champs essentiels"""
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"nip": self.code_nip,
|
||||||
|
"nom": self.nom,
|
||||||
|
"nom_usuel": self.nom_usuel,
|
||||||
|
"prenom": self.prenom,
|
||||||
|
"civilite": self.civilite,
|
||||||
|
}
|
||||||
|
|
||||||
|
def to_dict_scodoc7(self) -> dict:
|
||||||
"""Représentation dictionnaire,
|
"""Représentation dictionnaire,
|
||||||
compatible ScoDoc7 mais sans infos admission
|
compatible ScoDoc7 mais sans infos admission
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user