diff --git a/app/models/absences.py b/app/models/absences.py index 8653e5265c..e6e243b7c0 100644 --- a/app/models/absences.py +++ b/app/models/absences.py @@ -73,3 +73,17 @@ class BilletAbsence(db.Model): entry_date = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) # true si l'absence _pourrait_ etre justifiée justified = db.Column(db.Boolean(), default=False, server_default="false") + + def to_dict(self): + data = { + "id": self.id, + "billet_id": self.id, + "etudid": self.etudid, + "abs_begin": self.abs_begin, + "abs_end": self.abs_begin, + "description": self.description, + "etat": self.etat, + "entry_date": self.entry_date, + "justified": self.justified, + } + return data diff --git a/app/views/absences.py b/app/views/absences.py index 2b1df49759..7120e9909b 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -72,6 +72,7 @@ from app.decorators import ( from app.views import absences_bp as bp # --------------- +from app.models.absences import BilletAbsence from app.scodoc import sco_utils as scu from app.scodoc import notesdb as ndb from app import log @@ -1252,8 +1253,15 @@ def XMLgetBilletsEtud(etudid=False): @scodoc7func def listeBillets(): """Page liste des billets non traités et formulaire recherche d'un billet""" - cnx = ndb.GetDBConnexion() - billets = sco_abs.billet_absence_list(cnx, {"etat": False}) + # utilise Flask, jointure avec departement de l'étudiant + billets = ( + BilletAbsence.query.filter_by(etat=False) + .join(BilletAbsence.etudiant, aliased=True) + .filter_by(dept_id=g.scodoc_dept_id) + ) + # reconverti en dict pour les fonctions scodoc7 + billets = [b.to_dict() for b in billets] + # tab = _tableBillets(billets) T = tab.html() H = [