API: ajout moduleimpl-inscriptions

This commit is contained in:
Emmanuel Viennet 2023-09-20 12:45:24 +02:00
parent cee57234f2
commit 366bd0bea7
6 changed files with 37 additions and 3 deletions

View File

@ -559,6 +559,7 @@ def _create_singular(
data: dict, data: dict,
etud: Identite, etud: Identite,
) -> tuple[int, object]: ) -> tuple[int, object]:
"""TODO: documenter"""
errors: list[str] = [] errors: list[str] = []
# -- vérifications de l'objet json -- # -- vérifications de l'objet json --

View File

@ -67,3 +67,28 @@ def moduleimpl(moduleimpl_id: int):
query = query.join(FormSemestre).filter_by(dept_id=g.scodoc_dept_id) query = query.join(FormSemestre).filter_by(dept_id=g.scodoc_dept_id)
modimpl: ModuleImpl = query.first_or_404() modimpl: ModuleImpl = query.first_or_404()
return modimpl.to_dict(convert_objects=True) return modimpl.to_dict(convert_objects=True)
@bp.route("/moduleimpl/<int:moduleimpl_id>/inscriptions")
@api_web_bp.route("/moduleimpl/<int:moduleimpl_id>/inscriptions")
@login_required
@scodoc
@permission_required(Permission.ScoView)
@as_json
def moduleimpl_inscriptions(moduleimpl_id: int):
"""Liste des inscriptions à ce moduleimpl
Exemple de résultat :
[
{
"id": 1,
"etudid": 666,
"moduleimpl_id": 1234,
},
...
]
"""
query = ModuleImpl.query.filter_by(id=moduleimpl_id)
if g.scodoc_dept:
query = query.join(FormSemestre).filter_by(dept_id=g.scodoc_dept_id)
modimpl: ModuleImpl = query.first_or_404()
return [i.to_dict() for i in modimpl.inscriptions]

View File

@ -156,7 +156,7 @@ class Assiduite(db.Model):
external_data=external_data, external_data=external_data,
) )
else: else:
raise ScoValueError("L'étudiant n'est pas inscrit au moduleimpl") raise ScoValueError("L'étudiant n'est pas inscrit au module")
else: else:
nouv_assiduite = Assiduite( nouv_assiduite = Assiduite(
date_debut=date_debut, date_debut=date_debut,

View File

@ -219,6 +219,14 @@ class ModuleImplInscription(db.Model):
backref=db.backref("inscriptions", cascade="all, delete-orphan"), backref=db.backref("inscriptions", cascade="all, delete-orphan"),
) )
def to_dict(self) -> dict:
"dict repr."
return {
"id": self.id,
"etudid": self.etudid,
"moduleimpl_id": self.moduleimpl_id,
}
@classmethod @classmethod
def etud_modimpls_in_ue( def etud_modimpls_in_ue(
cls, formsemestre_id: int, etudid: int, ue_id: int cls, formsemestre_id: int, etudid: int, ue_id: int

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.6.31" SCOVERSION = "9.6.32"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"

View File

@ -889,7 +889,7 @@ def ajouter_assiduites(
test_assiduite["desc"], test_assiduite["desc"],
) )
except ScoValueError as excp: except ScoValueError as excp:
assert excp.args[0] == "L'étudiant n'est pas inscrit au moduleimpl" assert excp.args[0] == "L'étudiant n'est pas inscrit au module"
def verifier_comptage_et_filtrage_assiduites( def verifier_comptage_et_filtrage_assiduites(