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

View File

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

View File

@ -399,7 +399,7 @@ class ZScoDoc(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp
except: except:
admin_password_initialized = "0" admin_password_initialized = "0"
if isAdmin and admin_password_initialized != "1": 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!" "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}, parameters={"user_name": user_name},
) )
self._user_delete(user_name) self._user_delete(user_name)
REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
self.UsersURL() + r"?head_message=Utilisateur%20supprimé" 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 # The for used to edit this object
security.declareProtected(ScoView, "manage_editZScolar") security.declareProtected(ScoView, "manage_editZScolar")
def manage_editZScolar(self, title, RESPONSE=None): def manage_editZScolar(self, title, REQUEST=None):
"Changes the instance values" "Changes the instance values"
self.title = title self.title = title
self._p_changed = 1 self._p_changed = 1
RESPONSE.redirect("manage_editForm") return REQUEST.RESPONSE.redirect("manage_editForm")
def _setup_initial_roles_and_permissions(self): def _setup_initial_roles_and_permissions(self):
"""Initialize roles and permissions """Initialize roles and permissions
@ -321,43 +321,43 @@ REQUEST.URL0=%s<br/>
# essai: liste des permissions # essai: liste des permissions
# from AccessControl import getSecurityManager # pylint: disable=import-error # 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) # permissions = self.ac_inherited_permissions(1)
scoperms = [p for p in permissions if p[0][:3] == "Sco"] # scoperms = [p for p in permissions if p[0][:3] == "Sco"]
# H.append( str(self.aq_parent.aq_parent.permission_settings()) ) # # H.append( str(self.aq_parent.aq_parent.permission_settings()) )
# H.append('<p>perms: %s</p>'%str(scoperms)) # # H.append('<p>perms: %s</p>'%str(scoperms))
# H.append('<p>valid_roles: %s</p>'%str(self.valid_roles())) # # 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))) # # H.append('<p>ac_inherited_permissions=%s</p>'%str(self.ac_inherited_permissions(1)))
def collect_roles(context, rd): # def collect_roles(context, rd):
for p in scoperms: # for p in scoperms:
name, value = p[:2] # name, value = p[:2]
P = Permission(name, value, context) # P = Permission(name, value, context)
roles = list(P.getRoles()) # roles = list(P.getRoles())
if rd.has_key(name): # if rd.has_key(name):
rd[name] += roles # rd[name] += roles
else: # else:
rd[name] = roles # rd[name] = roles
if hasattr(context, "aq_parent"): # if hasattr(context, "aq_parent"):
collect_roles(context.aq_parent, rd) # collect_roles(context.aq_parent, rd)
b = "" # b = ""
rd = {} # rd = {}
collect_roles(self, rd) # collect_roles(self, rd)
b = "<p>" + str(rd) + "</p>" # b = "<p>" + str(rd) + "</p>"
authuser = REQUEST.AUTHENTICATED_USER # authuser = REQUEST.AUTHENTICATED_USER
for p in scoperms: # for p in scoperms:
permname, _ = p[:2] # permname, _ = p[:2]
b += "<p>" + permname + " : " # b += "<p>" + permname + " : "
if authuser.has_permission(permname, self): # if authuser.has_permission(permname, self):
b += "yes" # b += "yes"
else: # else:
b += "no" # b += "no"
b += "</p>" # b += "</p>"
b += "<p>xxx</p><hr><p>" + str(self.aq_parent.aq_parent) # 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: # essais calendriers:
security.declareProtected(ScoView, "experimental_calendar") security.declareProtected(ScoView, "experimental_calendar")
@ -1122,7 +1122,7 @@ REQUEST.URL0=%s<br/>
}, },
) )
logdb(REQUEST, cnx, method="addAnnotation", etudid=etudid) logdb(REQUEST, cnx, method="addAnnotation", etudid=etudid)
REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid) return REQUEST.RESPONSE.redirect("ficheEtud?etudid=" + etudid)
security.declareProtected(ScoView, "canSuppressAnnotation") security.declareProtected(ScoView, "canSuppressAnnotation")
@ -1161,7 +1161,7 @@ REQUEST.URL0=%s<br/>
logdb(REQUEST, cnx, method="SuppressAnnotation", etudid=etudid) logdb(REQUEST, cnx, method="SuppressAnnotation", etudid=etudid)
scolars.etud_annotations_delete(cnx, annotation_id) scolars.etud_annotations_delete(cnx, annotation_id)
REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
"ficheEtud?etudid=%s&amp;head_message=Annotation%%20supprimée" % (etudid) "ficheEtud?etudid=%s&amp;head_message=Annotation%%20supprimée" % (etudid)
) )
@ -1231,7 +1231,7 @@ REQUEST.URL0=%s<br/>
else: else:
scolars.adresse_create(cnx, args=tf[2]) scolars.adresse_create(cnx, args=tf[2])
logdb(REQUEST, cnx, method="changeCoordonnees", etudid=etudid) logdb(REQUEST, cnx, method="changeCoordonnees", etudid=etudid)
REQUEST.RESPONSE.redirect(dest_url) return REQUEST.RESPONSE.redirect(dest_url)
# --- Gestion des groupes: # --- Gestion des groupes:
security.declareProtected(ScoView, "affectGroups") 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) ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST)
if 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): 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], "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} args = {"formsemestre_id": formsemestre_id, "etat": etat}
context.do_formsemestre_edit(args) context.do_formsemestre_edit(args)
if REQUEST: if REQUEST:
REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id "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} args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat}
context.do_formsemestre_edit(args) context.do_formsemestre_edit(args)
if REQUEST: if REQUEST:
REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id "formsemestre_status?formsemestre_id=%s" % formsemestre_id
) )
return None
def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=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) raise ValueError("code choix invalide ! (%s)" % codechoice)
# #
Se.valide_decision(choice, REQUEST) # enregistre Se.valide_decision(choice, REQUEST) # enregistre
_redirect_valid_choice( return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
) )
@ -393,7 +393,7 @@ def formsemestre_validation_etud_manu(
# #
Se.valide_decision(choice, REQUEST) # enregistre Se.valide_decision(choice, REQUEST) # enregistre
if redirect: if redirect:
_redirect_valid_choice( return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
) )
@ -407,9 +407,9 @@ def _redirect_valid_choice(
) )
if sortcol: if sortcol:
adr += "&amp;sortcol=" + sortcol adr += "&amp;sortcol=" + sortcol
if desturl: # if desturl:
desturl += "&amp;desturl=" + desturl # desturl += "&amp;desturl=" + desturl
REQUEST.RESPONSE.redirect(adr) return REQUEST.RESPONSE.redirect(adr)
# Si le precedent a été modifié, demande relecture du parcours. # Si le precedent a été modifié, demande relecture du parcours.
# sinon renvoie au listing general, # sinon renvoie au listing general,

View File

@ -183,7 +183,7 @@ def moduleimpl_inscriptions_edit(
sco_moduleimpl.do_moduleimpl_inscrit_etuds( sco_moduleimpl.do_moduleimpl_inscrit_etuds(
context, moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST context, moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST
) )
REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
"moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id) "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>""") H.append("""</td></tr></table></div>""")
# Le formulaire de saisie des notes: # 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: if form is None:
return "" # redirect return REQUEST.RESPONSE.redirect(destination)
H.append(form) H.append(form)
# #
H.append("</div>") # /saisie_notes H.append("</div>") # /saisie_notes
@ -1041,7 +1047,7 @@ def _get_sorted_etuds(context, E, etudids, formsemestre_id):
return etuds 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 """Formulaire HTML saisie des notes dans l'évaluation E du moduleimpl M
pour les groupes indiqués. 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>''') # 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( tf = TF(
destination, destination,
REQUEST.form, REQUEST.form,
@ -1191,7 +1192,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
) )
H.append(tf.getform()) # check and init H.append(tf.getform()) # check and init
if tf.canceled(): if tf.canceled():
REQUEST.RESPONSE.redirect(destination)
return None return None
elif (not tf.submitted()) or not tf.result: elif (not tf.submitted()) or not tf.result:
# ajout formularie saisie notes manquantes # ajout formularie saisie notes manquantes
@ -1213,7 +1213,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
else: else:
# form submission # form submission
# rien à faire # rien à faire
REQUEST.RESPONSE.redirect(destination)
return None return None