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"] + sem["anneescolaire"]
) )
desc += " (" + sem["annee_debut"] + "/" + sem["annee_fin"] + ") " 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"] desc += " - " + sem["titre_num"]
return desc return desc

View File

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

View File

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

View File

@ -651,8 +651,16 @@ def formsemestre_description_table(
"Coef.": M["module"]["coefficient"], "Coef.": M["module"]["coefficient"],
# 'ECTS' : M['module']['ects'], # 'ECTS' : M['module']['ects'],
# Lien sur titre -> module # Lien sur titre -> module
"_Module_target": "moduleimpl_status?moduleimpl_id=" + M["moduleimpl_id"], "_Module_target": url_for(
"_Code_target": "moduleimpl_status?moduleimpl_id=" + M["moduleimpl_id"], "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) R.append(l)
if M["module"]["coefficient"]: if M["module"]["coefficient"]:

View File

@ -1222,7 +1222,13 @@ def group_rename(context, group_id, REQUEST=None):
+ html_sco_header.sco_footer() + html_sco_header.sco_footer()
) )
elif tf[0] == -1: 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: else:
# form submission # form submission
return group_set_name( 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() return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
elif tf[0] == -1: elif tf[0] == -1:
return flask.redirect( return flask.redirect(
scu.ScoURL() url_for(
+ "/Notes/moduleimpl_status?moduleimpl_id=" "notes.moduleimpl_status",
+ E["moduleimpl_id"] scodoc_dept=g.scodoc_dept,
moduleimpl_id=E["moduleimpl_id"],
)
) )
else: else:
sco_evaluations.do_evaluation_delete(E["evaluation_id"]) sco_evaluations.do_evaluation_delete(E["evaluation_id"])
return ( return (
"\n".join(H) "\n".join(H)
+ """<p>OK, évaluation supprimée.</p> + f"""<p>OK, évaluation supprimée.</p>
<p><a class="stdlink" href="%s">Continuer</a></p>""" <p><a class="stdlink" href="{
% ( url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept,
scu.ScoURL() moduleimpl_id=E["moduleimpl_id"])
+ "/Notes/moduleimpl_status?moduleimpl_id=" }">Continuer</a></p>"""
+ E["moduleimpl_id"]
)
+ html_sco_header.sco_footer() + html_sco_header.sco_footer()
) )

View File

@ -17,6 +17,7 @@ import requests
import urllib3 import urllib3
import pdb import pdb
from pprint import pprint as pp from pprint import pprint as pp
from flask import g, url_for
# A modifier pour votre serveur: # A modifier pour votre serveur:
CHECK_CERTIFICATE = False # set to True in production CHECK_CERTIFICATE = False # set to True in production
@ -108,7 +109,11 @@ print(
) )
print( print(
"Pour vérifier, aller sur: ", "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 # ---- Saisie d'une note