forked from ScoDoc/ScoDoc
ajout du code de abs_groupe_etat
This commit is contained in:
parent
53f3ec7294
commit
8c481bd0d1
@ -9,6 +9,7 @@ from app.models import Identite
|
||||
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import sco_abs
|
||||
from app.scodoc.sco_groups import get_group_members
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
||||
|
||||
@ -106,40 +107,68 @@ def absences_just(etudid: int = None):
|
||||
return jsonify(abs_just)
|
||||
|
||||
|
||||
# XXX TODO INACHEVEE
|
||||
# @bp.route(
|
||||
# "/absences/abs_group_etat/<int:group_id>",
|
||||
# methods=["GET"],
|
||||
# )
|
||||
# @bp.route(
|
||||
# "/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
|
||||
# methods=["GET"],
|
||||
# )
|
||||
# @token_auth.login_required
|
||||
# @token_permission_required(Permission.APIView)
|
||||
# def abs_groupe_etat( # XXX A REVOIR XXX
|
||||
# group_id: int, date_debut, date_fin, with_boursier=True, format="html"
|
||||
# ):
|
||||
# """
|
||||
# Liste des absences d'un ou plusieurs groupes entre deux dates
|
||||
# """
|
||||
# return error_response(501, message="Not implemented")
|
||||
@bp.route(
|
||||
"/absences/abs_group_etat/<int:group_id>",
|
||||
methods=["GET"],
|
||||
)
|
||||
@bp.route(
|
||||
"/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
|
||||
methods=["GET"],
|
||||
)
|
||||
@token_auth.login_required
|
||||
@token_permission_required(Permission.APIView)
|
||||
def abs_groupe_etat(group_id: int, date_debut=None, date_fin=None):
|
||||
"""
|
||||
Liste des absences d'un groupe (possibilité de choisir entre deux dates)
|
||||
|
||||
# # Fonction utilisée : app.scodoc.sco_groups.get_group_members() et app.scodoc.sco_abs.list_abs_date()
|
||||
group_id = l'id du groupe
|
||||
date_debut = None par défaut, sinon la date ISO du début de notre filtre
|
||||
date_fin = None par défaut, sinon la date ISO de la fin de notre filtre
|
||||
|
||||
# try:
|
||||
# # Utilisation de la fonction get_group_members
|
||||
# members = get_group_members(group_id)
|
||||
# except ValueError:
|
||||
# return error_response(
|
||||
# 404, message="La requête ne peut être traitée en l’état actuel"
|
||||
# )
|
||||
Exemple de résultat :
|
||||
[
|
||||
{
|
||||
"etudid": 1,
|
||||
"list_abs": []
|
||||
},
|
||||
{
|
||||
"etudid": 2,
|
||||
"list_abs": [
|
||||
{
|
||||
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
|
||||
"matin": true,
|
||||
"estabs": true,
|
||||
"estjust": true,
|
||||
"description": "",
|
||||
"begin": "2022-04-15 08:00:00",
|
||||
"end": "2022-04-15 11:59:59"
|
||||
},
|
||||
{
|
||||
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
|
||||
"matin": false,
|
||||
"estabs": true,
|
||||
"estjust": false,
|
||||
"description": "",
|
||||
"begin": "2022-04-15 12:00:00",
|
||||
"end": "2022-04-15 17:59:59"
|
||||
},
|
||||
]
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
# Fonction utilisée : app.scodoc.sco_groups.get_group_members() et app.scodoc.sco_abs.list_abs_date()
|
||||
|
||||
# data = []
|
||||
# # Filtre entre les deux dates renseignées
|
||||
# for member in members:
|
||||
# abs = sco_abs.list_abs_date(member.id, date_debut, date_fin)
|
||||
# data.append(abs)
|
||||
# Utilisation de la fonction get_group_members
|
||||
members = get_group_members(group_id)
|
||||
|
||||
# # return jsonify(data) # XXX TODO faire en sorte de pouvoir renvoyer sa (ex to_dict() dans absences)
|
||||
# return error_response(501, message="Not implemented")
|
||||
data = []
|
||||
# Filtre entre les deux dates renseignées
|
||||
for member in members:
|
||||
abs = {
|
||||
"etudid": member["etudid"],
|
||||
"list_abs": sco_abs.list_abs_date(member["etudid"], date_debut, date_fin),
|
||||
}
|
||||
data.append(abs)
|
||||
|
||||
return jsonify(data)
|
||||
|
Loading…
Reference in New Issue
Block a user