From 5df1d9010112e10a3afd579c00104a3fbd8f4079 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 27 Apr 2022 05:28:08 +0200 Subject: [PATCH] WIP: API absences --- app/api/absences.py | 12 +++--------- app/scodoc/sco_abs.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/api/absences.py b/app/api/absences.py index 7f33cb29..1388a704 100644 --- a/app/api/absences.py +++ b/app/api/absences.py @@ -1,20 +1,14 @@ #################################################### Absences ######################################################### -from datetime import datetime from flask import jsonify -from app import models from app.api import bp from app.api.errors import error_response from app.api.auth import token_permission_required from app.api.tools import get_etu_from_etudid_or_nip_or_ine -from app.scodoc import ndb +from app.scodoc import notesdb as ndb + from app.scodoc import sco_abs -from app.scodoc.sco_abs import ( - annule_absence, - annule_justif, - list_abs_date, -) from app.scodoc.sco_groups import get_group_members from app.scodoc.sco_permissions import Permission @@ -208,7 +202,7 @@ def abs_groupe_etat( # XXX A REVOIR XXX data = [] # Filtre entre les deux dates renseignées for member in members: - abs = list_abs_date(member.id, date_debut, date_fin) + abs = sco_abs.list_abs_date(member.id, date_debut, date_fin) data.append(abs) # return jsonify(data) # XXX TODO faire en sorte de pouvoir renvoyer sa (ex to_dict() dans absences) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index cd0f5d51..5dcca04c 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -425,16 +425,20 @@ def list_abs_date(etudid, beg_date=None, end_date=None): cursor.execute( """SELECT jour, matin, estabs, estjust, description FROM ABSENCES A WHERE A.ETUDID = %(etudid)s""" - + ("" if beg_date is None else """ + + ( + "" + if beg_date is None + else """ AND A.jour >= %(beg_date)s AND A.jour <= %(end_date)s """, - vars(), + vars(), + ) ) - Abs = cursor.dictfetchall() + absences = cursor.dictfetchall() # remove duplicates A = {} # { (jour, matin) : abs } - for a in Abs: + for a in absences: jour, matin = a["jour"], a["matin"] if (jour, matin) in A: # garde toujours la description