Fix: recherche étudiant

This commit is contained in:
Emmanuel Viennet 2021-09-09 08:03:43 +02:00
parent c6f6f45e0d
commit 4ac076ec6c
3 changed files with 16 additions and 13 deletions

View File

@ -190,9 +190,7 @@ def create_app(config_class=DevConfig):
sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy)
sco_bulletins_generator.register_bulletin_class(BulletinGeneratorStandard)
sco_bulletins_generator.register_bulletin_class(BulletinGeneratorUCAC)
app.logger.info(
f"registered bulletin classes {[ k for k in sco_bulletins_generator.BULLETIN_CLASSES ]}"
)
return app

View File

@ -120,10 +120,11 @@ def search_etud_in_dept(expnom=""):
if etudid is not None:
etuds = sco_etud.get_etud_info(filled=True, etudid=expnom)
if (etudid is None) or len(etuds) != 1:
if scu.is_valid_code_nip(expnom):
etuds = search_etuds_infos(code_nip=expnom)
expnom_str = str(expnom)
if scu.is_valid_code_nip(expnom_str):
etuds = search_etuds_infos(code_nip=expnom_str)
else:
etuds = search_etuds_infos(expnom=expnom)
etuds = search_etuds_infos(expnom=expnom_str)
else:
etuds = [] # si expnom est trop court, n'affiche rien
@ -151,7 +152,7 @@ def search_etud_in_dept(expnom=""):
H = [
html_sco_header.sco_header(
page_title="Recherche d'un étudiant",
no_side_bar=True,
no_side_bar=False,
init_qtip=True,
javascripts=["js/etud_info.js"],
)
@ -250,10 +251,12 @@ def search_etud_by_name(term: str) -> list:
r = ndb.SimpleDictFetch(
"""SELECT nom, prenom, code_nip
FROM identite
WHERE code_nip
LIKE %(beginning)s ORDER BY nom
WHERE
dept_id = %(dept_id)s
AND code_nip LIKE %(beginning)s
ORDER BY nom
""",
{"beginning": term + "%"},
{"beginning": term + "%", "dept_id": g.scodoc_dept_id},
)
data = [
{
@ -267,10 +270,12 @@ def search_etud_by_name(term: str) -> list:
r = ndb.SimpleDictFetch(
"""SELECT id AS etudid, nom, prenom
FROM identite
WHERE nom LIKE %(beginning)s
WHERE
dept_id = %(dept_id)s
AND nom LIKE %(beginning)s
ORDER BY nom
""",
{"beginning": term + "%"},
{"beginning": term + "%", "dept_id": g.scodoc_dept_id},
)
data = [

View File

@ -30,7 +30,7 @@
</p>
{% if current_user.is_authenticated %}
<form action="table_etud_in_accessible_depts" method="POST">
<form action="{{url_for('scodoc.table_etud_in_accessible_depts')}}" method="POST">
<b>Chercher étudiant:</b>
<input type="text" name="expnom" width="12" spellcheck="false" value="">
<input type="submit" value="Chercher">