forked from ScoDoc/ScoDoc
Implémentation de abs_group_etat
This commit is contained in:
parent
c0c4fd8a39
commit
6ba603f92a
@ -123,40 +123,69 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
return jsonify(abs_just)
|
return jsonify(abs_just)
|
||||||
|
|
||||||
|
|
||||||
# XXX TODO INACHEVEE
|
@bp.route(
|
||||||
# @bp.route(
|
"/absences/abs_group_etat/<int:group_id>",
|
||||||
# "/absences/abs_group_etat/<int:group_id>",
|
methods=["GET"],
|
||||||
# methods=["GET"],
|
)
|
||||||
# )
|
@bp.route(
|
||||||
# @bp.route(
|
"/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
|
||||||
# "/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
|
methods=["GET"],
|
||||||
# methods=["GET"],
|
)
|
||||||
# )
|
@token_auth.login_required
|
||||||
# @token_auth.login_required
|
@token_permission_required(Permission.APIView)
|
||||||
# @token_permission_required(Permission.APIView)
|
def abs_groupe_etat(group_id: int, date_debut=None, date_fin=None):
|
||||||
# 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 groupe (possibilité de choisir entre deux dates)
|
||||||
# ):
|
|
||||||
# """
|
|
||||||
# Liste des absences d'un ou plusieurs groupes entre deux dates
|
|
||||||
# """
|
|
||||||
# return error_response(501, message="Not implemented")
|
|
||||||
|
|
||||||
# # 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:
|
Exemple de résultat :
|
||||||
# # Utilisation de la fonction get_group_members
|
[
|
||||||
# members = get_group_members(group_id)
|
{
|
||||||
# except ValueError:
|
"etudid": 1,
|
||||||
# return error_response(
|
"list_abs": []
|
||||||
# 409, message="La requête ne peut être traitée en l’état actuel"
|
},
|
||||||
# )
|
{
|
||||||
|
"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 = []
|
# Utilisation de la fonction get_group_members
|
||||||
# # Filtre entre les deux dates renseignées
|
members = get_group_members(group_id)
|
||||||
# for member in members:
|
|
||||||
# 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)
|
data = []
|
||||||
# return error_response(501, message="Not implemented")
|
# Filtre entre les deux dates renseignées
|
||||||
|
for member in members:
|
||||||
|
print(member)
|
||||||
|
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