fix route recherche étudiant via JS

This commit is contained in:
Emmanuel Viennet 2021-08-31 08:21:30 +02:00
parent dca51d1ce4
commit 3ac4623421
4 changed files with 20 additions and 16 deletions

View File

@ -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:

View File

@ -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" : "<nip> <nom> <prenom>", "value" : etudid }
"""
may_be_nip = scu.is_valid_code_nip(term)
# term = term.upper() # conserve les accents
@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.0.6"
SCOVERSION = "9.0.7"
SCONAME = "ScoDoc"