diff --git a/app/api/tools.py b/app/api/tools.py index 7ed1a44e6..e1903f2db 100644 --- a/app/api/tools.py +++ b/app/api/tools.py @@ -15,7 +15,9 @@ from app.models import Departement, Identite, Admission from app.scodoc.sco_permissions import Permission -def get_etud(etudid=None, nip=None, ine=None) -> models.Identite: +def get_etud( + etudid: int | None = None, nip: str | None = None, ine: str | None = None +) -> models.Identite: """ L'instance d'étudiant la plus récente en fonction de l'etudid, ou du code nip ou code ine. @@ -29,6 +31,13 @@ def get_etud(etudid=None, nip=None, ine=None) -> models.Identite: allowed_depts = current_user.get_depts_with_permission(Permission.ScoView) if etudid is not None: + try: + etudid = int(etudid) + except ValueError: + return json_error( + 404, + message="etudid invalide", + ) query: Identite = Identite.query.filter_by(id=etudid) elif nip is not None: query = Identite.query.filter_by(code_nip=nip)