Commit 9c9e243a authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core] Use Base_redirect to jump to a module

This improve the compatibility with ERP5JS
parent 383fdb19
...@@ -3,6 +3,8 @@ portal = context.getPortalObject() ...@@ -3,6 +3,8 @@ portal = context.getPortalObject()
Base_translateString = portal.Base_translateString Base_translateString = portal.Base_translateString
checkPerm = portal.portal_membership.checkPermission checkPerm = portal.portal_membership.checkPermission
redirect_context = context
if jump_from_relative_url is None: if jump_from_relative_url is None:
relation = context relation = context
else: else:
...@@ -39,7 +41,6 @@ related_list = search_method(portal_type = portal_type) ...@@ -39,7 +41,6 @@ related_list = search_method(portal_type = portal_type)
relation_found = 0 relation_found = 0
if len(related_list) == 0: if len(related_list) == 0:
url = context.absolute_url()
message = Base_translateString( message = Base_translateString(
'No %s Related' % portal_type[0], 'No %s Related' % portal_type[0],
default=Base_translateString('No ${portal_type} related.', default=Base_translateString('No ${portal_type} related.',
...@@ -58,7 +59,7 @@ elif len(related_list) == 1: ...@@ -58,7 +59,7 @@ elif len(related_list) == 1:
form_id = target_form_id form_id = target_form_id
else: else:
form_id = 'view' form_id = 'view'
url = related_object.absolute_url() redirect_context = related_object
message = Base_translateString( message = Base_translateString(
# first, try to get a full translated message with portal types # first, try to get a full translated message with portal types
"%s related to %s." % (related_object.getPortalType(), context.getPortalType()), "%s related to %s." % (related_object.getPortalType(), context.getPortalType()),
...@@ -68,7 +69,6 @@ elif len(related_list) == 1: ...@@ -68,7 +69,6 @@ elif len(related_list) == 1:
"that_portal_type": context.getTranslatedPortalType(), "that_portal_type": context.getTranslatedPortalType(),
"that_title": context.getTitleOrId() }),) "that_title": context.getTitleOrId() }),)
else : else :
url = context.absolute_url()
message = Base_translateString("You are not authorised to view the related document.") message = Base_translateString("You are not authorised to view the related document.")
relation_found = 0 relation_found = 0
...@@ -105,25 +105,18 @@ else: ...@@ -105,25 +105,18 @@ else:
if obj is not None and checkPerm("View", obj): if obj is not None and checkPerm("View", obj):
related_object_list.append(obj) related_object_list.append(obj)
if len(related_object_list) == 0 : if len(related_object_list) == 0 :
url = context.absolute_url()
message = Base_translateString("You are not authorised to view any related document.") message = Base_translateString("You are not authorised to view any related document.")
relation_found = 0 relation_found = 0
else : else :
request=portal.REQUEST
selection_uid_list = [x.getUid() for x in related_object_list] selection_uid_list = [x.getUid() for x in related_object_list]
kw = {'uid': selection_uid_list} return context.Base_redirect(relation_form_id,
portal.portal_selections.setSelectionParamsFor( keep_items=dict(reset=1,
'Base_jumpToRelatedObjectList', kw) uid=selection_uid_list))
request.set('object_uid', context.getUid())
request.set('uids', selection_uid_list)
return getattr(context, relation_form_id)(
uids=selection_uid_list, REQUEST=request)
query_params = dict(portal_status_message=message) query_params = dict(portal_status_message=message)
if selection_name and not relation_found: if selection_name and not relation_found:
query_params['selection_name'] = selection_name query_params['selection_name'] = selection_name
query_params['selection_index'] = selection_index query_params['selection_index'] = selection_index
return redirect_context.Base_redirect(
redirect_url = '%s/%s?%s' % (url, form_id, make_query(query_params)) form_id, keep_items=query_params)
return context.REQUEST[ 'RESPONSE' ].redirect(redirect_url)
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