Commit 1a48ebbc authored by Georgios Dagkakis's avatar Georgios Dagkakis

erp5_core: update Base_edit so that it does not add two slashes in the computed url

Also, cleanup trailing whitespaces and unused variable.

new_url was not computated correctly either,
giving instance_url//erp5/...
parent eef2a772
...@@ -25,9 +25,12 @@ if dialog_id not in ('', None): ...@@ -25,9 +25,12 @@ if dialog_id not in ('', None):
# Prevent users who don't have rights to edit the object from # Prevent users who don't have rights to edit the object from
# editing it by calling the Base_edit script with correct # editing it by calling the Base_edit script with correct
# parameters directly. # parameters directly.
if not silent_mode and not request.AUTHENTICATED_USER.has_permission('Modify portal content', context) : if not silent_mode and not request.AUTHENTICATED_USER.has_permission('Modify portal content', context) :
msg = Base_translateString("You do not have the permissions to edit the object.") msg = Base_translateString("You do not have the permissions to edit the object.")
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&%s' % (context.absolute_url(), form_id, selection_index, selection_name, 'portal_status_message=%s' % msg) context_absolute_url = context.absolute_url()
context_absolute_url = context_absolute_url[:-1] if context_absolute_url.endswith('/') else context_absolute_url
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&%s' % (context_absolute_url, form_id, selection_index, selection_name, 'portal_status_message=%s' % msg)
return request['RESPONSE'].redirect(redirect_url) return request['RESPONSE'].redirect(redirect_url)
# Get the form # Get the form
...@@ -69,7 +72,7 @@ def editListBox(listbox_field, listbox): ...@@ -69,7 +72,7 @@ def editListBox(listbox_field, listbox):
if hasattr(value, 'edit'): if hasattr(value, 'edit'):
encapsulated_editor_list.append(value) encapsulated_editor_list.append(value)
else: else:
if value == '': if value == '':
value = None value = None
cleaned_v[key] = value cleaned_v[key] = value
...@@ -232,7 +235,7 @@ try: ...@@ -232,7 +235,7 @@ try:
elif(field_meta_type == 'MatrixBox'): elif(field_meta_type == 'MatrixBox'):
editMatrixBox(field, request.get(field.id)) editMatrixBox(field, request.get(field.id))
# Return parsed values # Return parsed values
if silent_mode: return (kw, encapsulated_editor_list), 'edit' if silent_mode: return (kw, encapsulated_editor_list), 'edit'
# Maybe we should build a list of objects we need # Maybe we should build a list of objects we need
...@@ -248,12 +251,6 @@ if message_only: ...@@ -248,12 +251,6 @@ if message_only:
ignore_layout = int(ignore_layout) ignore_layout = int(ignore_layout)
editable_mode = int(editable_mode) editable_mode = int(editable_mode)
spp = context.getPhysicalPath()
spp =list(spp)
s_url = request["SERVER_URL"]
spp.insert(0,s_url)
#calculate direct the url instead of using absolute_url
new_url = '/'.join(spp)
# for web mode, we should use 'view' instead of passed form_id # for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'. # after 'Save & View'.
...@@ -261,18 +258,20 @@ if context.REQUEST.get('is_web_mode', False) and \ ...@@ -261,18 +258,20 @@ if context.REQUEST.get('is_web_mode', False) and \
not editable_mode: not editable_mode:
form_id = 'view' form_id = 'view'
context_absolute_url = context.absolute_url()
context_absolute_url = context_absolute_url[:-1] if context_absolute_url.endswith('/') else context_absolute_url
if not selection_index: if not selection_index:
redirect_url = '%s/%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s' % ( redirect_url = '%s/%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s' % (
context.absolute_url(), context_absolute_url,
form_id, form_id,
ignore_layout, ignore_layout,
editable_mode, editable_mode,
message) message)
else: else:
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s' % ( redirect_url = '%s/%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s' % (
context.absolute_url(), context_absolute_url,
form_id, form_id,
selection_index, selection_index,
selection_name, selection_name,
...@@ -280,8 +279,7 @@ else: ...@@ -280,8 +279,7 @@ else:
editable_mode, editable_mode,
message) message)
result = request['RESPONSE'].redirect(redirect_url)
result = request['RESPONSE'].redirect(redirect_url)
if silent_mode: return result, 'redirect' if silent_mode: return result, 'redirect'
return result return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment