Fix: recherche etud, urls

This commit is contained in:
Emmanuel Viennet 2021-08-16 08:33:12 +02:00
parent 9313ffdb3b
commit 3d176a945f
6 changed files with 55 additions and 20 deletions

View File

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

View File

@ -872,8 +872,10 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
H.append('<p class="help indent">Aucun groupe dans cette partition')
if sco_groups.sco_permissions_check.can_change_groups(formsemestre_id):
H.append(
' (<a href="affectGroups?partition_id=%s" class="stdlink">créer</a>)'
% partition["partition_id"]
f""" (<a href="{url_for("scolar.affectGroups",
scodoc_dept=g.scodoc_dept,
partition_id=partition["partition_id"])
}" class="stdlink">créer</a>)"""
)
H.append("</p>")
if sco_groups.sco_permissions_check.can_change_groups(formsemestre_id):

View File

@ -924,8 +924,12 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
]
H.append(", ".join(lg))
H.append(
'</td><td><a class="stdlink" href="affectGroups?partition_id=%s">répartir</a></td>'
% p["partition_id"]
f"""</td><td><a class="stdlink" href="{
url_for("scolar.affectGroups",
scodoc_dept=g.scodoc_dept,
partition_id=p["partition_id"])
}">répartir</a></td>
"""
)
H.append(
'<td><a class="stdlink" href="partition_rename?partition_id=%s">renommer</a></td>'
@ -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)

View File

@ -392,9 +392,11 @@ def formsemestre_inscr_passage(
]
): # il y a au moins une vraie partition
H.append(
"""<li><a class="stdlink" href="affectGroups?partition_id=%s">Répartir les groupes de %s</a></li>
f"""<li><a class="stdlink" href="{
url_for("scolar.affectGroups",
scodoc_dept=g.scodoc_dept, partition_id=partition["partition_id"])
}">Répartir les groupes de {partition["partition_name"]}</a></li>
"""
% (partition["partition_id"], partition["partition_name"])
)
#

View File

@ -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(
"""<li><a class="stdlink" href="affectGroups?partition_id=%s">Répartir les groupes de %s</a></li>
f"""<li><a class="stdlink" href="{
url_for("scolar.affectGroups",
scodoc_dept=g.scodoc_dept,
partition_id=partitions[0]["partition_id"]
)}">Répartir les groupes de partitions[0]["partition_name"]</a></li>
"""
% (partitions[0]["partition_id"], partitions[0]["partition_name"])
)
H.append(footer)

View File

@ -809,7 +809,7 @@ def _gen_form_saisie_groupe(
'<td><a title=%s><input type="checkbox" name="abslist:list" value="%s" %s onclick="on_toggled(this, \'%s\', \'%s\')"/></a></td>'
% (
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(
'<input type="hidden" name="etudids" value="%s"/>'
% ",".join([etud["etudid"] for etud in etuds])
% ",".join([str(etud["etudid"]) for etud in etuds])
)
H.append('<input type="hidden" name="datedebut" value="%s"/>' % dates[0])
H.append('<input type="hidden" name="datefin" value="%s"/>' % dates[-1])