forked from ScoDoc/ScoDoc
Modification de /formsemestre/<int:formsemestre_id>/etudiants[/long]
Voir ligne 45 du tableur. - Ajout de la forme /long (permet d'avoir entre autre la date de naissance) - Ajout de la clé de tri (sort_key) - Résultat trié alphabétiquement. Exemple: pour 84 étudiants, on a une réponse de 105KB en format normal (short), et 230KB en format "long".
This commit is contained in:
parent
7f707d5a4c
commit
42f0cb8e76
@ -253,24 +253,42 @@ def formsemestre_programme(formsemestre_id: int):
|
|||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
"/formsemestre/<int:formsemestre_id>/etudiants",
|
"/formsemestre/<int:formsemestre_id>/etudiants",
|
||||||
defaults={"with_query": False},
|
defaults={"with_query": False, "long": False},
|
||||||
|
)
|
||||||
|
@bp.route(
|
||||||
|
"/formsemestre/<int:formsemestre_id>/etudiants/long",
|
||||||
|
defaults={"with_query": False, "long": True},
|
||||||
)
|
)
|
||||||
@bp.route(
|
@bp.route(
|
||||||
"/formsemestre/<int:formsemestre_id>/etudiants/query",
|
"/formsemestre/<int:formsemestre_id>/etudiants/query",
|
||||||
defaults={"with_query": True},
|
defaults={"with_query": True, "long": False},
|
||||||
|
)
|
||||||
|
@bp.route(
|
||||||
|
"/formsemestre/<int:formsemestre_id>/etudiants/long/query",
|
||||||
|
defaults={"with_query": True, "long": True},
|
||||||
)
|
)
|
||||||
@api_web_bp.route(
|
@api_web_bp.route(
|
||||||
"/formsemestre/<int:formsemestre_id>/etudiants",
|
"/formsemestre/<int:formsemestre_id>/etudiants",
|
||||||
defaults={"with_query": False},
|
defaults={"with_query": False, "long": False},
|
||||||
|
)
|
||||||
|
@api_web_bp.route(
|
||||||
|
"/formsemestre/<int:formsemestre_id>/etudiants/long",
|
||||||
|
defaults={"with_query": False, "long": True},
|
||||||
)
|
)
|
||||||
@api_web_bp.route(
|
@api_web_bp.route(
|
||||||
"/formsemestre/<int:formsemestre_id>/etudiants/query",
|
"/formsemestre/<int:formsemestre_id>/etudiants/query",
|
||||||
defaults={"with_query": True},
|
defaults={"with_query": True, "long": False},
|
||||||
|
)
|
||||||
|
@api_web_bp.route(
|
||||||
|
"/formsemestre/<int:formsemestre_id>/etudiants/long/query",
|
||||||
|
defaults={"with_query": True, "long": True},
|
||||||
)
|
)
|
||||||
@login_required
|
@login_required
|
||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
def formsemestre_etudiants(formsemestre_id: int, with_query: bool = False):
|
def formsemestre_etudiants(
|
||||||
|
formsemestre_id: int, with_query: bool = False, long: bool = False
|
||||||
|
):
|
||||||
"""Etudiants d'un formsemestre."""
|
"""Etudiants d'un formsemestre."""
|
||||||
query = FormSemestre.query.filter_by(id=formsemestre_id)
|
query = FormSemestre.query.filter_by(id=formsemestre_id)
|
||||||
if g.scodoc_dept:
|
if g.scodoc_dept:
|
||||||
@ -292,7 +310,10 @@ def formsemestre_etudiants(formsemestre_id: int, with_query: bool = False):
|
|||||||
else:
|
else:
|
||||||
inscriptions = formsemestre.inscriptions
|
inscriptions = formsemestre.inscriptions
|
||||||
|
|
||||||
etuds = [ins.etud.to_dict_short() for ins in inscriptions]
|
if long:
|
||||||
|
etuds = [ins.etud.to_dict_api() for ins in inscriptions]
|
||||||
|
else:
|
||||||
|
etuds = [ins.etud.to_dict_short() for ins in inscriptions]
|
||||||
# Ajout des groupes de chaque étudiants
|
# Ajout des groupes de chaque étudiants
|
||||||
# XXX A REVOIR: trop inefficace !
|
# XXX A REVOIR: trop inefficace !
|
||||||
for etud in etuds:
|
for etud in etuds:
|
||||||
@ -300,7 +321,7 @@ def formsemestre_etudiants(formsemestre_id: int, with_query: bool = False):
|
|||||||
etud["id"], formsemestre_id, exclude_default=True
|
etud["id"], formsemestre_id, exclude_default=True
|
||||||
)
|
)
|
||||||
|
|
||||||
return jsonify(etuds)
|
return jsonify(sorted(etuds, key=lambda e: e["sort_key"]))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formsemestre/<int:formsemestre_id>/etat_evals")
|
@bp.route("/formsemestre/<int:formsemestre_id>/etat_evals")
|
||||||
|
@ -149,13 +149,14 @@ class Identite(db.Model):
|
|||||||
"""Les champs essentiels"""
|
"""Les champs essentiels"""
|
||||||
return {
|
return {
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
|
"civilite": self.civilite,
|
||||||
"code_nip": self.code_nip,
|
"code_nip": self.code_nip,
|
||||||
"code_ine": self.code_ine,
|
"code_ine": self.code_ine,
|
||||||
"dept_id": self.dept_id,
|
"dept_id": self.dept_id,
|
||||||
"nom": self.nom,
|
"nom": self.nom,
|
||||||
"nom_usuel": self.nom_usuel,
|
"nom_usuel": self.nom_usuel,
|
||||||
"prenom": self.prenom,
|
"prenom": self.prenom,
|
||||||
"civilite": self.civilite,
|
"sort_key": self.sort_key,
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_dict_scodoc7(self) -> dict:
|
def to_dict_scodoc7(self) -> dict:
|
||||||
@ -217,6 +218,7 @@ class Identite(db.Model):
|
|||||||
e["adresses"] = [adr.to_dict() for adr in self.adresses]
|
e["adresses"] = [adr.to_dict() for adr in self.adresses]
|
||||||
e["dept_acronym"] = self.departement.acronym
|
e["dept_acronym"] = self.departement.acronym
|
||||||
e.pop("departement", None)
|
e.pop("departement", None)
|
||||||
|
e["sort_key"] = self.sort_key
|
||||||
return e
|
return e
|
||||||
|
|
||||||
def inscriptions(self) -> list["FormSemestreInscription"]:
|
def inscriptions(self) -> list["FormSemestreInscription"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user