Fix: autocomplete recherche etudiant

This commit is contained in:
Emmanuel Viennet 2021-02-16 22:07:56 +01:00
parent 96b22ac5ca
commit 5ffeae3e1f
2 changed files with 51 additions and 48 deletions

View File

@ -108,7 +108,7 @@ def search_etud_in_dept(
REQUEST=None,
):
"""Page recherche d'un etudiant
expnom est un regexp sur le nom ou un code_nip
expnom est un regexp sur le nom ou un code_nip ou un etudid
dest_url est la page sur laquelle on sera redirigé après choix
parameters spécifie des arguments additionnels à passer à l'URL (en plus de etudid)
"""
@ -134,7 +134,9 @@ def search_etud_in_dept(
etuds = search_etuds_infos(context, code_nip=expnom, REQUEST=REQUEST)
elif expnom:
etuds = search_etuds_infos(context, expnom=expnom, REQUEST=REQUEST)
else:
if expnom and not etuds:
etuds = context.getEtudInfo(filled=1, etudid=expnom, REQUEST=REQUEST)
if len(etuds) != 1:
etuds = []
if len(etuds) == 1:
# va directement a la destination
@ -268,14 +270,14 @@ def search_etud_by_name(context, term, REQUEST=None):
else:
r = ndb.SimpleDictFetch(
context,
"SELECT nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom",
"SELECT etudid, nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom",
{"beginning": term + "%"},
)
data = [
{
"label": "%s %s" % (x["nom"], scolars.format_prenom(x["prenom"])),
"value": x["nom"],
"value": x["etudid"],
}
for x in r
]

View File

@ -10,6 +10,7 @@ $(function() {
position: { collision: 'flip' }, // automatic menu position up/down
source: "search_etud_by_name",
select: function (event, ui) {
$("#in-expnom").val(ui.item.value);
$("#form-chercheetud").submit();
}
});