From 3ab3d398df19ec906207e967d046ab64f7828365 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 18 Aug 2022 15:43:14 +0200 Subject: [PATCH] Fix billets abs --- app/api/tools.py | 10 +++------- app/views/absences.py | 10 +++++++--- sco_version.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/api/tools.py b/app/api/tools.py index 08fd8aeb..90750e12 100644 --- a/app/api/tools.py +++ b/app/api/tools.py @@ -29,12 +29,8 @@ 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: - etud: Identite = Identite.query.get(etudid) - if (None in allowed_depts) or etud.departement.acronym in allowed_depts: - return etud - return None # accès interdit => pas d'étudiant - - if nip is not None: + query: Identite = Identite.query.filter_by(id=etudid) + elif nip is not None: query = Identite.query.filter_by(code_nip=nip) elif ine is not None: query = Identite.query.filter_by(code_ine=ine) @@ -45,7 +41,7 @@ def get_etud(etudid=None, nip=None, ine=None) -> models.Identite: ) if None not in allowed_depts: # restreint aux départements autorisés: - etuds = etuds.join(Departement).filter( + query = query.join(Departement).filter( or_(Departement.acronym == acronym for acronym in allowed_depts) ) return query.join(Admission).order_by(desc(Admission.annee)).first() diff --git a/app/views/absences.py b/app/views/absences.py index 28f17ef7..829fb2d4 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -72,6 +72,7 @@ from app.decorators import ( ) from app.models import FormSemestre, GroupDescr from app.models.absences import BilletAbsence +from app.models.etudiants import Identite from app.views import absences_bp as bp # --------------- @@ -1099,7 +1100,7 @@ def AddBilletAbsence( begin, end, description, - etudid=False, + etudid=None, code_nip=None, code_ine=None, justified=True, @@ -1114,7 +1115,7 @@ def AddBilletAbsence( end = str(end) code_nip = str(code_nip) if code_nip else None - etud = api.tools.get_etud(etudid=None, nip=None, ine=None) + etud = api.tools.get_etud(etudid=etudid, nip=code_nip, ine=code_ine) # check dates begin_date = dateutil.parser.isoparse(begin) # may raises ValueError end_date = dateutil.parser.isoparse(end) @@ -1212,9 +1213,12 @@ def billets_etud(etudid=False): @scodoc @permission_required_compat_scodoc7(Permission.ScoView) @scodoc7func -def XMLgetBilletsEtud(etudid=False): +def XMLgetBilletsEtud(etudid=False, code_nip=False): """Liste billets pour un etudiant""" log("Warning: called deprecated XMLgetBilletsEtud") + if etudid is False: + etud = Identite.query.filter_by(code_nip=str(code_nip)).first_or_404() + etudid = etud.id table = sco_abs_billets.table_billets_etud(etudid) if table: return table.make_page(format="xml") diff --git a/sco_version.py b/sco_version.py index 436982a2..f840d9de 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.25" +SCOVERSION = "9.3.26" SCONAME = "ScoDoc"