diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index b717daea00..e2a40ed4c2 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -403,9 +403,7 @@ def next_ue_numero(formation_id, semestre_id=None): return ue_list[-1]["numero"] + 1000 -def ue_delete( - ue_id=None, delete_validations=False, dialog_confirmed=False, REQUEST=None -): +def ue_delete(ue_id=None, delete_validations=False, dialog_confirmed=False): """Delete an UE""" ue = do_ue_list(args={"ue_id": ue_id}) if not ue: diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index 027276d9b1..2d828ee6c5 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -231,10 +231,11 @@ def search_etuds_infos(expnom=None, code_nip=None): return etuds -def search_etud_by_name(term, REQUEST=None): +def search_etud_by_name(term: str) -> list: """Recherche noms étudiants par début du nom, pour autocomplete Accepte aussi un début de code NIP (au moins 6 caractères) - Renvoie une liste de nom en JSON + Renvoie une liste de dicts + { "label" : " ", "value" : etudid } """ may_be_nip = scu.is_valid_code_nip(term) # term = term.upper() # conserve les accents @@ -264,9 +265,9 @@ def search_etud_by_name(term, REQUEST=None): ] else: r = ndb.SimpleDictFetch( - """SELECT id AS etudid, nom, prenom - FROM identite - WHERE nom LIKE %(beginning)s + """SELECT id AS etudid, nom, prenom + FROM identite + WHERE nom LIKE %(beginning)s ORDER BY nom """, {"beginning": term + "%"}, @@ -279,8 +280,7 @@ def search_etud_by_name(term, REQUEST=None): } for x in r ] - # log(data) - return scu.sendJSON(REQUEST, data) + return data # ---------- Recherche sur plusieurs département diff --git a/app/views/scolar.py b/app/views/scolar.py index 7d817cc30f..54640bea23 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -40,8 +40,8 @@ from zipfile import ZipFile import psycopg2 import flask -from flask import g, url_for -from flask import current_app +from flask import jsonify, url_for +from flask import current_app, g, request from flask_login import current_user from config import Config @@ -320,9 +320,15 @@ sco_publish( methods=["GET", "POST"], ) -sco_publish( - "/search_etud_by_name", sco_find_etud.search_etud_by_name, Permission.ScoView -) + +@bp.route("/search_etud_by_name") +@bp.route("/Notes/search_etud_by_name") # for JS apis +@scodoc +@permission_required(Permission.ScoView) +def search_etud_by_name(): + term = request.args["term"] + data = sco_find_etud.search_etud_by_name(term) + return jsonify(data) # XMLgetEtudInfos était le nom dans l'ancienne API ScoDoc 6 diff --git a/sco_version.py b/sco_version.py index ae606040c9..1ad266134e 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.6" +SCOVERSION = "9.0.7" SCONAME = "ScoDoc"