From 4ac076ec6c2efc15aa42936c62057f7d8079c1fb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 9 Sep 2021 08:03:43 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20recherche=20=C3=A9tudiant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 4 +--- app/scodoc/sco_find_etud.py | 23 ++++++++++++++--------- app/templates/scodoc.html | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 9d450cd7..c0cbdad5 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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 diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index 2d828ee6..13426bea 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -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 = [ diff --git a/app/templates/scodoc.html b/app/templates/scodoc.html index 240389bb..23826e3c 100644 --- a/app/templates/scodoc.html +++ b/app/templates/scodoc.html @@ -30,7 +30,7 @@

{% if current_user.is_authenticated %} -
+ Chercher étudiant: