forked from ScoDoc/DocScoDoc
Fix billets abs
This commit is contained in:
parent
d630aaabb3
commit
3ab3d398df
@ -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()
|
||||
|
@ -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")
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.3.25"
|
||||
SCOVERSION = "9.3.26"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user