Fix: url_for

This commit is contained in:
Emmanuel Viennet 2021-08-15 22:08:38 +02:00
parent 1d1513f782
commit 483df70465
7 changed files with 48 additions and 22 deletions

View File

@ -87,7 +87,7 @@ def print_semestres_description(sems, avec_affichage_debug=False):
+ sem["anneescolaire"]
)
desc += " (" + sem["annee_debut"] + "/" + sem["annee_fin"] + ") "
desc += str(sem["formation_id"]) + " / " + sem["formsemestre_id"]
desc += str(sem["formation_id"]) + " / " + str(sem["formsemestre_id"])
desc += " - " + sem["titre_num"]
return desc

View File

@ -883,15 +883,21 @@ def formsemestre_evaluations_delai_correction(
e["delai_correction"] = None
e["module_code"] = Mod["code"]
e["_module_code_target"] = (
"moduleimpl_status?moduleimpl_id=" + M["moduleimpl_id"]
e["_module_code_target"] = url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=M["moduleimpl_id"],
)
e["module_titre"] = Mod["titre"]
e["responsable_id"] = M["responsable_id"]
e["responsable_nomplogin"] = sco_users.user_info(M["responsable_id"])[
"nomplogin"
]
e["_jour_target"] = "evaluation_listenotes?evaluation_id=" + e["evaluation_id"]
e["_jour_target"] = url_for(
"notes.evaluation_listenotes",
scodoc_dept=g.scodoc_dept,
evaluation_id=e["evaluation_id"],
)
T.append(e)
columns_ids = (

View File

@ -28,6 +28,7 @@
"""Menu "custom" (défini par l'utilisateur) dans les semestres
"""
import flask
from flask import g, url_for
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
@ -105,18 +106,18 @@ def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
for item in menu:
descr.append(
(
"title_" + item["custommenu_id"],
"title_" + str(item["custommenu_id"]),
{"size": 40, "template": '<tr><td class="tf-field">%(elem)s</td>'},
)
)
descr.append(
(
"url_" + item["custommenu_id"],
"url_" + str(item["custommenu_id"]),
{"size": 80, "template": '<td class="tf-field">%(elem)s</td></tr>'},
)
)
initvalues["title_" + item["custommenu_id"]] = item["title"]
initvalues["url_" + item["custommenu_id"]] = item["url"]
initvalues["title_" + str(item["custommenu_id"])] = item["title"]
initvalues["url_" + str(item["custommenu_id"])] = item["url"]
tf = TrivialFormulator(
REQUEST.URL0,
REQUEST.form,

View File

@ -651,8 +651,16 @@ def formsemestre_description_table(
"Coef.": M["module"]["coefficient"],
# 'ECTS' : M['module']['ects'],
# Lien sur titre -> module
"_Module_target": "moduleimpl_status?moduleimpl_id=" + M["moduleimpl_id"],
"_Code_target": "moduleimpl_status?moduleimpl_id=" + M["moduleimpl_id"],
"_Module_target": url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=M["moduleimpl_id"],
),
"_Code_target": url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=M["moduleimpl_id"],
),
}
R.append(l)
if M["module"]["coefficient"]:

View File

@ -1222,7 +1222,13 @@ def group_rename(context, group_id, REQUEST=None):
+ html_sco_header.sco_footer()
)
elif tf[0] == -1:
return flask.redirect("affectGroups?partition_id=" + group["partition_id"])
return flask.redirect(
url_for(
"scolar.affectGroups",
scodoc_dept=g.scodoc_dept,
partition_id=group["partition_id"],
)
)
else:
# form submission
return group_set_name(

View File

@ -1494,21 +1494,21 @@ def evaluation_delete(context, REQUEST, evaluation_id):
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
elif tf[0] == -1:
return flask.redirect(
scu.ScoURL()
+ "/Notes/moduleimpl_status?moduleimpl_id="
+ E["moduleimpl_id"]
url_for(
"notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept,
moduleimpl_id=E["moduleimpl_id"],
)
)
else:
sco_evaluations.do_evaluation_delete(E["evaluation_id"])
return (
"\n".join(H)
+ """<p>OK, évaluation supprimée.</p>
<p><a class="stdlink" href="%s">Continuer</a></p>"""
% (
scu.ScoURL()
+ "/Notes/moduleimpl_status?moduleimpl_id="
+ E["moduleimpl_id"]
)
+ f"""<p>OK, évaluation supprimée.</p>
<p><a class="stdlink" href="{
url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept,
moduleimpl_id=E["moduleimpl_id"])
}">Continuer</a></p>"""
+ html_sco_header.sco_footer()
)

View File

@ -17,6 +17,7 @@ import requests
import urllib3
import pdb
from pprint import pprint as pp
from flask import g, url_for
# A modifier pour votre serveur:
CHECK_CERTIFICATE = False # set to True in production
@ -108,7 +109,11 @@ print(
)
print(
"Pour vérifier, aller sur: ",
BASEURL + "/Notes/moduleimpl_status?moduleimpl_id=" + mod["moduleimpl_id"],
url_for(
"notes.moduleimpl_status",
scodoc_dept="DEPT",
moduleimpl_id=mod["moduleimpl_id"],
),
)
# ---- Saisie d'une note