Commit cdfafc60 authored by Georgios Dagkakis's avatar Georgios Dagkakis

products and several BTs: Fix calculations of urls using Base_constructUrlFor

parent f098d723
......@@ -60,4 +60,6 @@ if document.getValidationState() not in validation_state:
web_section = context.getWebSectionValue()
if web_section is None:
web_section = context
return "%s%s" % (web_section.absolute_url(), reference)
return web_section.Base_constructUrlFor(
document_reference=reference
)
......@@ -5,17 +5,14 @@
tal:define="dummy here/setupCurrentSkin;" />
<tal:block tal:define="response request/RESPONSE;
came_from python: request.get('came_from') or request.get('field_came_from');
absolute_url python: here.absolute_url();
absolute_url python: absolute_url[:-1] if absolute_url.endswith('/') else absolute_url;
isAnon here/portal_membership/isAnonymousUser | nothing;
url_topmost_document python: here.Base_getURLTopmostDocumentValue();
url_topmost_document_absolute_url python: url_topmost_document.absolute_url();
url_topmost_document_absolute_url python: url_topmost_document_absolute_url[:-1] if url_topmost_document_absolute_url.endswith('/') else url_topmost_document_absolute_url;
came_from_valid python: not came_from or url_topmost_document.isURLAncestorOf(came_from);">
<tal:block tal:condition="isAnon">
<tal:block tal:define="dummy python: response.expireCookie('__ac', path='/');
url python: '%s/login_form?portal_status_message=%s' % (absolute_url, here.Base_translateString('Login and/or password is incorrect.'));
url python: came_from and '%s&amp;came_from=%s' % (url, came_from) or url;
parameter_dict python: {'portal_status_message': here.Base_translateString('Login and/or password is incorrectXXX.')};
parameter_dict python: parameter_dict.update({'came_from': came_from}) if came_from else parameter_dict;
url python: here.Base_constructUrlFor(form_id='login_form', parameter_dict=parameter_dict);
dummy python: response.redirect(url);" />
</tal:block>
<tal:block tal:condition="not: isAnon">
......@@ -23,7 +20,7 @@
<tal:block tal:define="dummy python: response.redirect(came_from or here.getPermanentURL(here));" />
</tal:block>
<tal:block tal:condition="not: came_from_valid">
<tal:block tal:define="dummy python: response.redirect('%s?portal_status_message=%s' % (url_topmost_document_absolute_url, here.Base_translateString('Redirection to an external site prevented.')));" />
<tal:block tal:define="dummy python: response.redirect(url_topmost_document.Base_constructUrlFor(parameter_dict={'portal_status_message': here.Base_translateString('Redirection to an external site prevented.')}))" />
</tal:block>
</tal:block>
</tal:block>
......
......@@ -4,6 +4,6 @@
"""
if document.hasReference():
file_name = document.Document_getStandardFileName()
return "%s%s" % (context.absolute_url(), file_name)
return context.Base_constructUrlFor(document_reference=file_name)
else:
return "%s%s" % (document.getAbsoluteUrl(),view and '/view' or '')
return context.Base_constructUrlFor(form_id='view' if view else None)
......@@ -15,15 +15,13 @@ default_language = web_section.getLayoutProperty("default_available_language", d
website_url_set = {}
#simplify code of Base_doLanguage, can't ues Base_doLanguage directly
root_website_url = web_section.getOriginalDocument().absolute_url()
root_website_url = root_website_url[:-1] if root_website_url.endswith('/') else root_website_url
root_website_url = web_section.getOriginalDocument().Base_constructUrlFor()
website_url_pattern = r'^%s(?:%s)*(/|$)' % (
re.escape(root_website_url),
'|'.join('/' + re.escape(x) for x in available_language_set))
for language in available_language_set:
web_section_url = web_section.absolute_url()
web_section_url = web_section_url[:-1] if web_section_url.endswith('/') else web_section_url
web_section_url = web_section.Base_constructUrlFor()
if language == default_language:
website_url_set[language] = re.sub(website_url_pattern, r'%s/\1' % root_website_url, web_section_url)
else:
......
......@@ -27,10 +27,14 @@ if dialog_id not in ('', None):
# parameters directly.
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.")
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)
redirect_url = context.Base_constructUrlFor(
form_id=form_id,
parameter_dict={
'selection_index': selection_index,
'selection_name': selection_name,
'portal_status_message': Base_translateString("You do not have the permissions to edit the object.")
}
)
return request['RESPONSE'].redirect(redirect_url)
# Get the form
......@@ -258,27 +262,26 @@ if context.REQUEST.get('is_web_mode', False) and \
not editable_mode:
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:
redirect_url = '%s/%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s' % (
context_absolute_url,
form_id,
ignore_layout,
editable_mode,
message)
redirect_url = context.Base_constructUrlFor(
form_id=form_id,
parameter_dict={
'ignore_layout:int': ignore_layout,
'editable_mode:int': editable_mode,
'portal_status_message': message,
}
)
else:
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s' % (
context_absolute_url,
form_id,
selection_index,
selection_name,
ignore_layout,
editable_mode,
message)
redirect_url = context.Base_constructUrlFor(
form_id=form_id,
parameter_dict={
'selection_index': selection_index,
'selection_name': selection_name,
'ignore_layout:int': ignore_layout,
'editable_mode:int': editable_mode,
'portal_status_message': message,
}
)
result = request['RESPONSE'].redirect(redirect_url)
if silent_mode: return result, 'redirect'
......
......@@ -9,8 +9,7 @@ if website is not None and website.isStaticLanguageSelection():
# Web Mode
root_website = website.getOriginalDocument()
default_language = root_website.getDefaultAvailableLanguage()
root_website_url = root_website.absolute_url()
root_website_url = root_website_url[:-1] if root_website_url.endswith('/') else root_website_url
root_website_url = root_website.Base_constructUrlFor()
website_url_pattern = r'^%s(?:%s)*(/|$)' % (
re.escape(root_website_url),
'|'.join('/' + re.escape(x) for x in root_website.getAvailableLanguageList()))
......
......@@ -9,8 +9,7 @@
local_parameter_list local_parameter_list | python: {};
action_context python: portal.restrictedTraverse(request.get('object_path', '?'), here);
global actions python: here.Base_filterDuplicateActions(portal.portal_actions.listFilteredActionsFor(action_context));
absolute_url here/absolute_url;
global url python: absolute_url[:-1] if absolute_url.endswith('/') else absolute_url;
global url python: here.Base_constructUrlFor();
global current_form_id python: local_parameter_list.get('dialog_id', local_parameter_list.get('form_id', 'view'));
dummy python: request.set('current_form_id', current_form_id);
global current_url python: '%s/%s' % (url, current_form_id);
......
portal = context.getPortalObject()
if portal.portal_skins.updateSkinCookie():
portal.setupCurrentSkin()
url = REQUEST.get("came_from")
came_from = REQUEST.get("came_from")
if portal.portal_membership.isAnonymousUser():
RESPONSE.expireCookie("__ac", path="/")
absolute_url = context.absolute_url()
absolute_url = absolute_url[:-1] if absolute_url.endswith('/') else absolute_url
url = "%s/login_form?portal_status_message=%s" % (
absolute_url,
context.Base_translateString("Login and/or password is incorrect.")
+ ("&amp;came_from=" + url if url else ""))
elif not url:
url = context.absolute_url()
parameter_dict = {'portal_status_message': context.Base_translateString("Login and/or password is incorrect.")}
if came_from:
parameter_dict['came_from'] = came_from
url = context.Base_constructUrlFor(
form_id='login_form',
parameter_dict=parameter_dict
)
elif came_from:
url = came_from
else:
url = context.Base_constructUrlFor()
topmost_url_document = context.Base_getURLTopmostDocumentValue()
if not topmost_url_document.isURLAncestorOf(url):
return context.ERP5Site_redirect(topmost_url_document.absolute_url(),
return context.ERP5Site_redirect(topmost_url_document.Base_constructUrlFor(),
keep_items={'portal_status_message': 'Redirection to an external site prevented.'})
return RESPONSE.redirect(url)
......@@ -521,8 +521,7 @@ class FolderMixIn(ExtensionClass.Base):
not access any document in given path,
hence it does not compute the inner acquisition path.
"""
document_url = self.absolute_url()
document_url = document_url[:-1] if document_url.endswith('/') else document_url
document_url = self.Base_constructUrlFor()
parsed_given_url = urlparse(given_url)
parsed_document_url = urlparse(document_url)
# XXX note that the following check:
......
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