From 36c22a7ca704884fe31604832da9ab60bedcb5f1 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 28 Sep 2021 09:59:50 +0200 Subject: [PATCH] =?UTF-8?q?Liste=20billest=20d'absences=20restreinte=20au?= =?UTF-8?q?=20d=C3=A9partement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/absences.py | 14 ++++++++++++++ app/views/absences.py | 12 ++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) 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 = [