From 2bb0ac548dc68dc3b4f5f21e8c4eea2cd290c4a5 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Mon, 16 May 2022 16:04:33 +0200 Subject: [PATCH] merge from master --- app/api/etudiants.py | 2 +- app/api/evaluations.py | 1 + app/api/tools.py | 1 - app/models/evaluations.py | 2 -- app/scodoc/sco_recapcomplet.py | 4 +++- app/views/notes.py | 2 +- sco_version.py | 2 +- tests/api/exemple-api-basic.py | 4 +++- tests/api/setup_test_api.py | 1 + tests/api/tools_test_api.py | 2 ++ 10 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index e53056f1a..3784e9383 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -278,7 +278,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None) # ) @token_auth.login_required @token_permission_required(Permission.APIView) -def etudiant_bulletin_semestre( # XXX TODO Ajouter la possibilité de retourner en version pdf +def etudiant_bulletin_semestre( # XXX TODO Ajouter la possibilité de retourner en version pdf formsemestre_id, etudid: int = None, nip: str = None, diff --git a/app/api/evaluations.py b/app/api/evaluations.py index 7d7f9e1a6..f72b85bd1 100644 --- a/app/api/evaluations.py +++ b/app/api/evaluations.py @@ -4,6 +4,7 @@ from flask import jsonify import app from app import models +from app.models import Evaluation from app.api import bp from app.api.auth import token_auth, token_permission_required from app.api.errors import error_response diff --git a/app/api/tools.py b/app/api/tools.py index 462a5cbf8..75b8cad49 100644 --- a/app/api/tools.py +++ b/app/api/tools.py @@ -39,4 +39,3 @@ def get_last_instance_etud_from_etudid_or_nip_or_ine( etud = query.first() return etud - diff --git a/app/models/evaluations.py b/app/models/evaluations.py index afe8e791a..ef2a62887 100644 --- a/app/models/evaluations.py +++ b/app/models/evaluations.py @@ -5,8 +5,6 @@ import datetime from app import db -from app.models import formsemestre -from app.models.formsemestre import FormSemestre from app.models.moduleimpls import ModuleImpl from app.models.ues import UniteEns diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index bbb1aee0c..1c5c19eb4 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -32,7 +32,7 @@ import time from xml.etree import ElementTree from flask import g, request -from flask import url_for +from flask import abort, url_for from app import log from app.but import bulletin_but @@ -83,6 +83,8 @@ def formsemestre_recapcomplet( force_publishing: publie les xml et json même si bulletins non publiés selected_etudid: etudid sélectionné (pour scroller au bon endroit) """ + if not isinstance(formsemestre_id, int): + abort(404) formsemestre = FormSemestre.query.get_or_404(formsemestre_id) file_formats = {"csv", "json", "xls", "xlsx", "xlsall", "xml"} supported_formats = file_formats | {"html", "evals"} diff --git a/app/views/notes.py b/app/views/notes.py index 86c4f6f73..f924acb92 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -292,7 +292,7 @@ def formsemestre_bulletinetud( format = format or "html" if not isinstance(formsemestre_id, int): - raise ValueError("formsemestre_id must be an integer !") + abort(404, description="formsemestre_id must be an integer !") formsemestre = FormSemestre.query.get_or_404(formsemestre_id) if etudid: etud = models.Identite.query.get_or_404(etudid) diff --git a/sco_version.py b/sco_version.py index aaeef2963..120447d32 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.20" +SCOVERSION = "9.2.21" SCONAME = "ScoDoc" diff --git a/tests/api/exemple-api-basic.py b/tests/api/exemple-api-basic.py index 1c7d61b8a..a581a8783 100644 --- a/tests/api/exemple-api-basic.py +++ b/tests/api/exemple-api-basic.py @@ -33,7 +33,7 @@ except NameError: load_dotenv(os.path.join(BASEDIR, ".env")) CHK_CERT = bool(int(os.environ.get("CHECK_CERTIFICATE", False))) -SCODOC_URL = os.environ["SCODOC_URL"] +SCODOC_URL = os.environ["SCODOC_URL"] or "http://localhost:5000" API_URL = SCODOC_URL + "/ScoDoc/api" SCODOC_USER = os.environ["SCODOC_USER"] SCODOC_PASSWORD = os.environ["SCODOC_PASSWORD"] @@ -110,6 +110,8 @@ print("\n".join([s["titre_num"] for s in sems])) sems = GET(f"/etudiant/nip/{code_nip}/formsemestres") print("\n".join([s["titre_num"] for s in sems])) +# Evaluation +evals = GET("/evaluations/1") # # --- Recupere la liste de tous les semestres: # sems = GET(s, "Notes/formsemestre_list?format=json", "Aucun semestre !") diff --git a/tests/api/setup_test_api.py b/tests/api/setup_test_api.py index 4a9d45393..9791a975e 100644 --- a/tests/api/setup_test_api.py +++ b/tests/api/setup_test_api.py @@ -25,6 +25,7 @@ SCODOC_URL = os.environ["SCODOC_URL"] API_URL = SCODOC_URL + "/ScoDoc/api" API_USER = os.environ.get("API_USER", "test") API_PASSWORD = os.environ.get("API_PASSWD", "test") +DEPT_ACRONYM = "TAPI" print(f"SCODOC_URL={SCODOC_URL}") print(f"API URL={API_URL}") diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py index 40d443810..e2a36510a 100644 --- a/tests/api/tools_test_api.py +++ b/tests/api/tools_test_api.py @@ -49,6 +49,8 @@ ETUD_FIELDS = { "code_nip", "codepostaldomicile", "date_naissance", + "dept_acronym", + "dept_id", "dept_naissance", "description", "domicile",