From f0ce0b574e758373234547ce36d87121d79eefdf Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Wed, 27 Apr 2022 15:29:09 +0200 Subject: [PATCH] =?UTF-8?q?correction=20sco=5Fabs.py=20+=20petites=20modif?= =?UTF-8?q?ications=20sur=20diff=C3=A9rents=20fichiers=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/absences.py | 2 +- app/api/departements.py | 79 +++++++++++++++--------------- app/api/formsemestres.py | 2 +- app/api/jury.py | 70 +------------------------- app/api/remiser.py | 65 ++++++++++++++++++++++++ app/scodoc/sco_abs.py | 14 +++--- tests/api/test_api_formsemestre.py | 2 +- 7 files changed, 118 insertions(+), 116 deletions(-) diff --git a/app/api/absences.py b/app/api/absences.py index 7af0eac64..35abe34ff 100644 --- a/app/api/absences.py +++ b/app/api/absences.py @@ -70,7 +70,7 @@ def absences(etudid: int = None, nip: int = None, ine: int = None): @bp.route("/absences/nip//just", methods=["GET"]) @bp.route("/absences/ine//just", methods=["GET"]) @token_permission_required(Permission.APIView) -def absences_justify(etudid: int = None, nip: int = None, ine: int = None): +def absences_just(etudid: int = None, nip: int = None, ine: int = None): """ Retourne la liste des absences justifiées d'un étudiant donné diff --git a/app/api/departements.py b/app/api/departements.py index e915b8210..b47144905 100644 --- a/app/api/departements.py +++ b/app/api/departements.py @@ -40,7 +40,8 @@ def liste_etudiants(dept: str, formsemestre_id=None): formsemestre_id: l'id d'un formesemestre Exemple de résultat : - { + [ + { "civilite": "X", "code_ine": null, "code_nip": null, @@ -50,8 +51,8 @@ def liste_etudiants(dept: str, formsemestre_id=None): "etudid": 18, "nom": "MOREL", "prenom": "JACQUES" - }, - { + }, + { "civilite": "X", "code_ine": null, "code_nip": null, @@ -61,8 +62,9 @@ def liste_etudiants(dept: str, formsemestre_id=None): "etudid": 19, "nom": "FOURNIER", "prenom": "ANNE" - }, - ... + }, + ... + ] """ # Si le formsemestre_id a été renseigné if formsemestre_id is not None: @@ -96,39 +98,39 @@ def liste_semestres_courant(dept: str): dept: l'acronym d'un département Exemple de résultat : - [ - { - "titre": "master machine info", - "gestion_semestrielle": false, - "scodoc7_id": null, - "date_debut": "01/09/2021", - "bul_bgcolor": null, - "date_fin": "15/12/2022", - "resp_can_edit": false, - "dept_id": 1, - "etat": true, - "resp_can_change_ens": false, - "id": 1, - "modalite": "FI", - "ens_can_edit_eval": false, - "formation_id": 1, - "gestion_compensation": false, - "elt_sem_apo": null, - "semestre_id": 1, - "bul_hide_xml": false, - "elt_annee_apo": null, - "block_moyennes": false, - "formsemestre_id": 1, - "titre_num": "master machine info semestre 1", - "date_debut_iso": "2021-09-01", - "date_fin_iso": "2022-12-15", - "responsables": [ - 3, - 2 - ] - }, - ... - ] + [ + { + "titre": "master machine info", + "gestion_semestrielle": false, + "scodoc7_id": null, + "date_debut": "01/09/2021", + "bul_bgcolor": null, + "date_fin": "15/12/2022", + "resp_can_edit": false, + "dept_id": 1, + "etat": true, + "resp_can_change_ens": false, + "id": 1, + "modalite": "FI", + "ens_can_edit_eval": false, + "formation_id": 1, + "gestion_compensation": false, + "elt_sem_apo": null, + "semestre_id": 1, + "bul_hide_xml": false, + "elt_annee_apo": null, + "block_moyennes": false, + "formsemestre_id": 1, + "titre_num": "master machine info semestre 1", + "date_debut_iso": "2021-09-01", + "date_fin_iso": "2022-12-15", + "responsables": [ + 3, + 2 + ] + }, + ... + ] """ # Récupération des départements comportant l'acronym mit en paramètre dept = models.Departement.query.filter_by(acronym=dept).first_or_404() @@ -248,7 +250,6 @@ def semestre_index(dept: str, formsemestre_id: int): ... ] } - """ app.set_sco_dept(dept) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 5167fa07e..22bb770ee 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -13,7 +13,7 @@ from app.scodoc.sco_permissions import Permission from app.scodoc.sco_pvjury import formsemestre_pvjury -@bp.route("/formations/formsemestre/", methods=["GET"]) +@bp.route("/formsemestre/", methods=["GET"]) @token_permission_required(Permission.APIView) def formsemestre(formsemestre_id: int): """ diff --git a/app/api/jury.py b/app/api/jury.py index 664e982b0..982280776 100644 --- a/app/api/jury.py +++ b/app/api/jury.py @@ -10,7 +10,7 @@ from app.scodoc.sco_pvjury import formsemestre_pvjury @bp.route("/jury/formsemestre//preparation_jury", methods=["GET"]) -# @token_permission_required(Permission.) +# @token_permission_required(Permission.?) def jury_preparation(formsemestre_id: int): """ Retourne la feuille de préparation du jury @@ -26,7 +26,7 @@ def jury_preparation(formsemestre_id: int): @bp.route("/jury/formsemestre//decisions_jury", methods=["GET"]) -# @token_permission_required(Permission.) +# @token_permission_required(Permission.?) def jury_decisions(formsemestre_id: int): """ Retourne les décisions du jury suivant un formsemestre donné @@ -39,69 +39,3 @@ def jury_decisions(formsemestre_id: int): decision_jury = formsemestre_pvjury(formsemestre_id) return error_response(501, message="Not implemented") - - -@bp.route( - "/jury/set_decision/etudid?etudid=&formsemestre_id=" - "&jury=&devenir=&assiduite=", - methods=["POST"], -) -@bp.route( - "/jury/set_decision/nip?etudid=&formsemestre_id=" - "&jury=&devenir=&assiduite=", - methods=["POST"], -) -@bp.route( - "/jury/set_decision/ine?etudid=&formsemestre_id=" - "&jury=&devenir=&assiduite=", - methods=["POST"], -) -# @token_permission_required(Permission.) -def set_decision_jury( - formsemestre_id: int, - decision_jury: str, - devenir_jury: str, - assiduite: bool, - etudid: int = None, - nip: int = None, - ine: int = None, -): - """ - Attribuer la décision du jury et le devenir à un etudiant - - formsemestre_id : l'id d'un formsemestre - decision_jury : la décision du jury - devenir_jury : le devenir du jury - assiduite : True ou False - etudid : l'etudid d'un étudiant - nip: le code nip d'un étudiant - ine : le code ine d'un étudiant - """ - return error_response(501, message="Not implemented") - - -@bp.route( - "/jury/etudid//formsemestre//annule_decision", - methods=["DELETE"], -) -@bp.route( - "/jury/nip//formsemestre//annule_decision", - methods=["DELETE"], -) -@bp.route( - "/jury/ine//formsemestre//annule_decision", - methods=["DELETE"], -) -# @token_permission_required(Permission.) -def annule_decision_jury( - formsemestre_id: int, etudid: int = None, nip: int = None, ine: int = None -): - """ - Supprime la déciosion du jury pour un étudiant donné - - formsemestre_id : l'id d'un formsemestre - etudid : l'etudid d'un étudiant - nip: le code nip d'un étudiant - ine : le code ine d'un étudiant - """ - return error_response(501, message="Not implemented") diff --git a/app/api/remiser.py b/app/api/remiser.py index 83ade511e..156a4c5fd 100644 --- a/app/api/remiser.py +++ b/app/api/remiser.py @@ -186,3 +186,68 @@ # ) # return error_response(200, message="OK") + +# @bp.route( +# "/jury/set_decision/etudid?etudid=&formsemestre_id=" +# "&jury=&devenir=&assiduite=", +# methods=["POST"], +# ) +# @bp.route( +# "/jury/set_decision/nip?etudid=&formsemestre_id=" +# "&jury=&devenir=&assiduite=", +# methods=["POST"], +# ) +# @bp.route( +# "/jury/set_decision/ine?etudid=&formsemestre_id=" +# "&jury=&devenir=&assiduite=", +# methods=["POST"], +# ) +# # @token_permission_required(Permission.) +# def set_decision_jury( +# formsemestre_id: int, +# decision_jury: str, +# devenir_jury: str, +# assiduite: bool, +# etudid: int = None, +# nip: int = None, +# ine: int = None, +# ): +# """ +# Attribuer la décision du jury et le devenir à un etudiant +# +# formsemestre_id : l'id d'un formsemestre +# decision_jury : la décision du jury +# devenir_jury : le devenir du jury +# assiduite : True ou False +# etudid : l'etudid d'un étudiant +# nip: le code nip d'un étudiant +# ine : le code ine d'un étudiant +# """ +# return error_response(501, message="Not implemented") +# +# +# @bp.route( +# "/jury/etudid//formsemestre//annule_decision", +# methods=["DELETE"], +# ) +# @bp.route( +# "/jury/nip//formsemestre//annule_decision", +# methods=["DELETE"], +# ) +# @bp.route( +# "/jury/ine//formsemestre//annule_decision", +# methods=["DELETE"], +# ) +# # @token_permission_required(Permission.) +# def annule_decision_jury( +# formsemestre_id: int, etudid: int = None, nip: int = None, ine: int = None +# ): +# """ +# Supprime la déciosion du jury pour un étudiant donné +# +# formsemestre_id : l'id d'un formsemestre +# etudid : l'etudid d'un étudiant +# nip: le code nip d'un étudiant +# ine : le code ine d'un étudiant +# """ +# return error_response(501, message="Not implemented") diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 5dcca04cb..890f4a540 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -420,21 +420,23 @@ WHERE A.ETUDID = %(etudid)s def list_abs_date(etudid, beg_date=None, end_date=None): """Liste des absences et justifs entre deux dates (inclues).""" + print("On rentre") cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) + print("Juste avant le SQL") + 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(), ) + absences = cursor.dictfetchall() # remove duplicates A = {} # { (jour, matin) : abs } diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index 7117c39b5..a16d751ae 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -24,7 +24,7 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS # formsemestre def test_formsemestre(): r = requests.get( - SCODOC_URL + "/ScoDoc/api/formations/formsemestre/1", + SCODOC_URL + "/ScoDoc/api/formsemestre/1", headers=HEADERS, verify=CHECK_CERTIFICATE, )