Fix billets abs

This commit is contained in:
Emmanuel Viennet 2022-08-18 15:43:14 +02:00
parent d630aaabb3
commit 3ab3d398df
3 changed files with 11 additions and 11 deletions

View File

@ -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) allowed_depts = current_user.get_depts_with_permission(Permission.ScoView)
if etudid is not None: if etudid is not None:
etud: Identite = Identite.query.get(etudid) query: Identite = Identite.query.filter_by(id=etudid)
if (None in allowed_depts) or etud.departement.acronym in allowed_depts: elif nip is not None:
return etud
return None # accès interdit => pas d'étudiant
if nip is not None:
query = Identite.query.filter_by(code_nip=nip) query = Identite.query.filter_by(code_nip=nip)
elif ine is not None: elif ine is not None:
query = Identite.query.filter_by(code_ine=ine) 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: if None not in allowed_depts:
# restreint aux départements autorisés: # 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) or_(Departement.acronym == acronym for acronym in allowed_depts)
) )
return query.join(Admission).order_by(desc(Admission.annee)).first() return query.join(Admission).order_by(desc(Admission.annee)).first()

View File

@ -72,6 +72,7 @@ from app.decorators import (
) )
from app.models import FormSemestre, GroupDescr from app.models import FormSemestre, GroupDescr
from app.models.absences import BilletAbsence from app.models.absences import BilletAbsence
from app.models.etudiants import Identite
from app.views import absences_bp as bp from app.views import absences_bp as bp
# --------------- # ---------------
@ -1099,7 +1100,7 @@ def AddBilletAbsence(
begin, begin,
end, end,
description, description,
etudid=False, etudid=None,
code_nip=None, code_nip=None,
code_ine=None, code_ine=None,
justified=True, justified=True,
@ -1114,7 +1115,7 @@ def AddBilletAbsence(
end = str(end) end = str(end)
code_nip = str(code_nip) if code_nip else None 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 # check dates
begin_date = dateutil.parser.isoparse(begin) # may raises ValueError begin_date = dateutil.parser.isoparse(begin) # may raises ValueError
end_date = dateutil.parser.isoparse(end) end_date = dateutil.parser.isoparse(end)
@ -1212,9 +1213,12 @@ def billets_etud(etudid=False):
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func @scodoc7func
def XMLgetBilletsEtud(etudid=False): def XMLgetBilletsEtud(etudid=False, code_nip=False):
"""Liste billets pour un etudiant""" """Liste billets pour un etudiant"""
log("Warning: called deprecated XMLgetBilletsEtud") 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) table = sco_abs_billets.table_billets_etud(etudid)
if table: if table:
return table.make_page(format="xml") return table.make_page(format="xml")

View File

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