1
0
forked from ScoDoc/ScoDoc

Fix all redirects for Flask compatibility

This commit is contained in:
IDK 2021-02-07 15:31:35 +01:00
parent 154e7bf3e8
commit 8d7ec2faea
11 changed files with 75 additions and 75 deletions

View File

@ -562,7 +562,7 @@ class ZEntreprises(
% entreprise_contact_id
)
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
etudok = sco_entreprises.do_entreprise_check_etudiant(
self, tf[2]["etudiant"]
@ -572,7 +572,7 @@ class ZEntreprises(
else:
tf[2].update({"etudid": etudok[1]})
sco_entreprises.do_entreprise_contact_edit(self, tf[2])
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
self.EntreprisesURL()
+ "/entreprise_contact_list?entreprise_id="
+ str(c["entreprise_id"])
@ -680,13 +680,13 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"%s/entreprise_correspondant_list?entreprise_id=%s"
% (self.EntreprisesURL(), c["entreprise_id"])
)
else:
sco_entreprises.do_entreprise_correspondant_edit(self, tf[2])
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"%s/entreprise_correspondant_list?entreprise_id=%s"
% (self.EntreprisesURL(), c["entreprise_id"])
)
@ -789,7 +789,7 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
etudok = sco_entreprises.do_entreprise_check_etudiant(
self, tf[2]["etudiant"]
@ -799,7 +799,7 @@ class ZEntreprises(
else:
tf[2].update({"etudid": etudok[1]})
sco_entreprises.do_entreprise_contact_create(self, tf[2])
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
H.append(entreprise_footer(self, REQUEST))
return "\n".join(H)
@ -828,12 +828,12 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
sco_entreprises.do_entreprise_contact_delete(
self, c["entreprise_contact_id"]
)
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
H.append(entreprise_footer(self, REQUEST))
return "\n".join(H)
@ -935,10 +935,10 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
sco_entreprises.do_entreprise_correspondant_create(self, tf[2])
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
H.append(entreprise_footer(self, REQUEST))
return "\n".join(H)
@ -967,12 +967,12 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
sco_entreprises.do_entreprise_correspondant_delete(
self, c["entreprise_corresp_id"]
)
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
H.append(entreprise_footer(self, REQUEST))
return "\n".join(H)
@ -1025,10 +1025,10 @@ class ZEntreprises(
if tf[0] == 0:
H.append(tf[1])
elif tf[0] == -1:
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
else:
sco_entreprises.do_entreprise_delete(self, E["entreprise_id"])
REQUEST.RESPONSE.redirect(self.EntreprisesURL())
return REQUEST.RESPONSE.redirect(self.EntreprisesURL())
H.append(entreprise_footer(self, REQUEST))
return "\n".join(H)

View File

@ -169,7 +169,7 @@ class ZNotes(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Impl
"Changes the instance values"
self.title = title
self._p_changed = 1
RESPONSE.redirect("manage_editForm")
return RESPONSE.redirect("manage_editForm")
def _getNotesCache(self):
"returns CacheNotesTable instance for us"

View File

@ -399,7 +399,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
except:
admin_password_initialized = "0"
if isAdmin and admin_password_initialized != "1":
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"ScoDoc/change_admin_user_form?message=Le%20mot%20de%20passe%20administrateur%20doit%20etre%20change%20!"
)

View File

@ -1072,7 +1072,7 @@ class ZScoUsers(
parameters={"user_name": user_name},
)
self._user_delete(user_name)
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
self.UsersURL() + r"?head_message=Utilisateur%20supprimé"
)

View File

@ -206,11 +206,11 @@ class ZScolar(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
# The for used to edit this object
security.declareProtected(ScoView, "manage_editZScolar")
def manage_editZScolar(self, title, RESPONSE=None):
def manage_editZScolar(self, title, REQUEST=None):
"Changes the instance values"
self.title = title
self._p_changed = 1
RESPONSE.redirect("manage_editForm")
return REQUEST.RESPONSE.redirect("manage_editForm")
def _setup_initial_roles_and_permissions(self):
"""Initialize roles and permissions
@ -321,43 +321,43 @@ REQUEST.URL0=%s<br/>
# essai: liste des permissions
# from AccessControl import getSecurityManager # pylint: disable=import-error
from AccessControl.Permission import Permission # pylint: disable=import-error
# from AccessControl.Permission import Permission # pylint: disable=import-error
permissions = self.ac_inherited_permissions(1)
scoperms = [p for p in permissions if p[0][:3] == "Sco"]
# H.append( str(self.aq_parent.aq_parent.permission_settings()) )
# H.append('<p>perms: %s</p>'%str(scoperms))
# H.append('<p>valid_roles: %s</p>'%str(self.valid_roles()))
# H.append('<p>ac_inherited_permissions=%s</p>'%str(self.ac_inherited_permissions(1)))
def collect_roles(context, rd):
for p in scoperms:
name, value = p[:2]
P = Permission(name, value, context)
roles = list(P.getRoles())
if rd.has_key(name):
rd[name] += roles
else:
rd[name] = roles
if hasattr(context, "aq_parent"):
collect_roles(context.aq_parent, rd)
# permissions = self.ac_inherited_permissions(1)
# scoperms = [p for p in permissions if p[0][:3] == "Sco"]
# # H.append( str(self.aq_parent.aq_parent.permission_settings()) )
# # H.append('<p>perms: %s</p>'%str(scoperms))
# # H.append('<p>valid_roles: %s</p>'%str(self.valid_roles()))
# # H.append('<p>ac_inherited_permissions=%s</p>'%str(self.ac_inherited_permissions(1)))
# def collect_roles(context, rd):
# for p in scoperms:
# name, value = p[:2]
# P = Permission(name, value, context)
# roles = list(P.getRoles())
# if rd.has_key(name):
# rd[name] += roles
# else:
# rd[name] = roles
# if hasattr(context, "aq_parent"):
# collect_roles(context.aq_parent, rd)
b = ""
rd = {}
collect_roles(self, rd)
b = "<p>" + str(rd) + "</p>"
# b = ""
# rd = {}
# collect_roles(self, rd)
# b = "<p>" + str(rd) + "</p>"
authuser = REQUEST.AUTHENTICATED_USER
for p in scoperms:
permname, _ = p[:2]
b += "<p>" + permname + " : "
if authuser.has_permission(permname, self):
b += "yes"
else:
b += "no"
b += "</p>"
b += "<p>xxx</p><hr><p>" + str(self.aq_parent.aq_parent)
# authuser = REQUEST.AUTHENTICATED_USER
# for p in scoperms:
# permname, _ = p[:2]
# b += "<p>" + permname + " : "
# if authuser.has_permission(permname, self):
# b += "yes"
# else:
# b += "no"
# b += "</p>"
# b += "<p>xxx</p><hr><p>" + str(self.aq_parent.aq_parent)
return self.sco_header(REQUEST) + str(b) + self.sco_footer(REQUEST)
# return self.sco_header(REQUEST) + str(b) + self.sco_footer(REQUEST)
# essais calendriers:
security.declareProtected(ScoView, "experimental_calendar")
@ -1122,7 +1122,7 @@ REQUEST.URL0=%s<br/>
},
)
logdb(REQUEST, cnx, method="addAnnotation", etudid=etudid)
REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid)
return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid)
security.declareProtected(ScoView, "canSuppressAnnotation")
@ -1161,7 +1161,7 @@ REQUEST.URL0=%s<br/>
logdb(REQUEST, cnx, method="SuppressAnnotation", etudid=etudid)
scolars.etud_annotations_delete(cnx, annotation_id)
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"ficheEtud?etudid=%s&amp;head_message=Annotation%%20supprimée" % (etudid)
)
@ -1231,7 +1231,7 @@ REQUEST.URL0=%s<br/>
else:
scolars.adresse_create(cnx, args=tf[2])
logdb(REQUEST, cnx, method="changeCoordonnees", etudid=etudid)
REQUEST.RESPONSE.redirect(dest_url)
return REQUEST.RESPONSE.redirect(dest_url)
# --- Gestion des groupes:
security.declareProtected(ScoView, "affectGroups")

View File

@ -452,7 +452,7 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None)
ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST)
if REQUEST:
REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id)
return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id)
def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):

View File

@ -156,4 +156,4 @@ def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
"url": tf[2]["url_" + custommenu_id],
},
)
REQUEST.RESPONSE.redirect(dest_url)
return REQUEST.RESPONSE.redirect(dest_url)

View File

@ -1438,7 +1438,7 @@ def formsemestre_change_lock(
args = {"formsemestre_id": formsemestre_id, "etat": etat}
context.do_formsemestre_edit(args)
if REQUEST:
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
)
@ -1478,9 +1478,10 @@ def formsemestre_change_publication_bul(
args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat}
context.do_formsemestre_edit(args)
if REQUEST:
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
)
return None
def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=None):

View File

@ -346,7 +346,7 @@ def formsemestre_validation_etud(
raise ValueError("code choix invalide ! (%s)" % codechoice)
#
Se.valide_decision(choice, REQUEST) # enregistre
_redirect_valid_choice(
return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
)
@ -393,7 +393,7 @@ def formsemestre_validation_etud_manu(
#
Se.valide_decision(choice, REQUEST) # enregistre
if redirect:
_redirect_valid_choice(
return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
)
@ -407,9 +407,9 @@ def _redirect_valid_choice(
)
if sortcol:
adr += "&amp;sortcol=" + sortcol
if desturl:
desturl += "&amp;desturl=" + desturl
REQUEST.RESPONSE.redirect(adr)
# if desturl:
# desturl += "&amp;desturl=" + desturl
return REQUEST.RESPONSE.redirect(adr)
# Si le precedent a été modifié, demande relecture du parcours.
# sinon renvoie au listing general,

View File

@ -183,7 +183,7 @@ def moduleimpl_inscriptions_edit(
sco_moduleimpl.do_moduleimpl_inscrit_etuds(
context, moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST
)
REQUEST.RESPONSE.redirect(
return REQUEST.RESPONSE.redirect(
"moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id)
)
#

View File

@ -949,9 +949,15 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
H.append("""</td></tr></table></div>""")
# Le formulaire de saisie des notes:
form = _form_saisie_notes(context, E, M, groups_infos.group_ids, REQUEST=REQUEST)
destination = "%s/Notes/moduleimpl_status?moduleimpl_id=%s" % (
context.ScoURL(),
E["moduleimpl_id"],
)
form = _form_saisie_notes(
context, E, M, groups_infos.group_ids, destination=destination, REQUEST=REQUEST
)
if form is None:
return "" # redirect
return REQUEST.RESPONSE.redirect(destination)
H.append(form)
#
H.append("</div>") # /saisie_notes
@ -1041,7 +1047,7 @@ def _get_sorted_etuds(context, E, etudids, formsemestre_id):
return etuds
def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
"""Formulaire HTML saisie des notes dans l'évaluation E du moduleimpl M
pour les groupes indiqués.
@ -1176,11 +1182,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
)
# H.append('''<div id="sco_msg" class="head_message"></div>''')
destination = "%s/Notes/moduleimpl_status?moduleimpl_id=%s" % (
context.ScoURL(),
M["moduleimpl_id"],
)
tf = TF(
destination,
REQUEST.form,
@ -1191,7 +1192,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
)
H.append(tf.getform()) # check and init
if tf.canceled():
REQUEST.RESPONSE.redirect(destination)
return None
elif (not tf.submitted()) or not tf.result:
# ajout formularie saisie notes manquantes
@ -1213,7 +1213,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
else:
# form submission
# rien à faire
REQUEST.RESPONSE.redirect(destination)
return None