From 3d176a945f7077bd6289c7241b1e6cf19e8f7142 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 16 Aug 2021 08:33:12 +0200 Subject: [PATCH] Fix: recherche etud, urls --- app/scodoc/notesdb.py | 30 ++++++++++++++++++++------- app/scodoc/sco_formsemestre_status.py | 6 ++++-- app/scodoc/sco_groups.py | 20 ++++++++++++++---- app/scodoc/sco_inscr_passage.py | 6 ++++-- app/scodoc/sco_synchro_etuds.py | 9 ++++++-- app/views/absences.py | 4 ++-- 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 796f6edf..f6af848b 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -171,18 +171,32 @@ def DBSelectArgs( cl.append("T0.%s = T%d.%s" % (id_name, i, aux_id)) i = i + 1 cond += " and ".join(cl) - # Traitement des expressions régulières: - # n'autorise pas d'expressions - if test == "~": - for k in vals.keys(): - vals[k] = vals[k].translate(_SQL_REMOVE_BAD_CHARS) if vals: if aux_tables: # paren cond += " AND ( " - cond += operator.join( - ["T0.%s%s%%(%s)s" % (x, test, x) for x in vals.keys() if vals[x] != None] - ) + + if test == "~": + # Traitement des expressions régulières: + # n'autorise pas d'expressions + explist = [] + for k in vals.keys(): + # n'applique ~ qu'aux strings + if isinstance(vals[k], str): + vals[k] = vals[k].translate(_SQL_REMOVE_BAD_CHARS) + explist.append("T0.%s~%%(%s)s" % (k, k)) + elif vals[k] is not None: + explist.append("T0.%s=%%(%s)s" % (k, k)) + cond += operator.join(explist) + else: + cond += operator.join( + [ + "T0.%s%s%%(%s)s" % (x, test, x) + for x in vals.keys() + if vals[x] != None + ] + ) + # conditions sur NULLs: cnuls = " and ".join( ["T0.%s is NULL" % x for x in vals.keys() if vals[x] is None] ) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index a60a66cf..651ea515 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -872,8 +872,10 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True): H.append('

Aucun groupe dans cette partition') if sco_groups.sco_permissions_check.can_change_groups(formsemestre_id): H.append( - ' (créer)' - % partition["partition_id"] + f""" (créer)""" ) H.append("

") if sco_groups.sco_permissions_check.can_change_groups(formsemestre_id): diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 838ba010..90883aef 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -924,8 +924,12 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None): ] H.append(", ".join(lg)) H.append( - 'répartir' - % p["partition_id"] + f"""répartir + """ ) H.append( 'renommer' @@ -1185,7 +1189,13 @@ def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1): # redirect to partition edit page: if redirect: - return flask.redirect("affectGroups?partition_id=" + str(group["partition_id"])) + return flask.redirect( + url_for( + "scolar.affectGroups", + scodoc_dept=g.scodoc_dept, + partition_id=group["partition_id"], + ) + ) def group_rename(context, group_id, REQUEST=None): @@ -1245,7 +1255,9 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None): partition = get_partition(context, partition_id) formsemestre_id = partition["formsemestre_id"] # renvoie sur page édition groupes - dest_url = "affectGroups?partition_id=%s" % partition_id + dest_url = url_for( + "scolar.affectGroups", scodoc_dept=g.scodoc_dept, partition_id=partition_id + ) if not sco_permissions_check.can_change_groups(formsemestre_id): raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 3383e7ad..7b2476a3 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -392,9 +392,11 @@ def formsemestre_inscr_passage( ] ): # il y a au moins une vraie partition H.append( - """
  • Répartir les groupes de %s
  • + f"""
  • Répartir les groupes de {partition["partition_name"]}
  • """ - % (partition["partition_id"], partition["partition_name"]) ) # diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index ae606fb7..7a3db217 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -32,6 +32,8 @@ import time import pprint from operator import itemgetter +from flask import g, url_for + import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb from app.scodoc import html_sco_header @@ -254,9 +256,12 @@ def formsemestre_synchro_etuds( ) if partitions: # il y a au moins une vraie partition H.append( - """
  • Répartir les groupes de %s
  • + f"""
  • Répartir les groupes de partitions[0]["partition_name"]
  • """ - % (partitions[0]["partition_id"], partitions[0]["partition_name"]) ) H.append(footer) diff --git a/app/views/absences.py b/app/views/absences.py index c5591f18..d6f628d7 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -809,7 +809,7 @@ def _gen_form_saisie_groupe( '' % ( bulle_pm, - etudid + ":" + date + ":" + "pm", + str(etudid) + ":" + date + ":" + "pm", checked, etudid, date + ":pm", @@ -820,7 +820,7 @@ def _gen_form_saisie_groupe( # place la liste des etudiants et les dates pour pouvoir effacer les absences H.append( '' - % ",".join([etud["etudid"] for etud in etuds]) + % ",".join([str(etud["etudid"]) for etud in etuds]) ) H.append('' % dates[0]) H.append('' % dates[-1])