Commit 0f81fe49 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Type: only include ERP5JS workflow jumps when developer mode is enabled

We should not show a link to jump to workflow configuration to end users, these
are not relevant to them and can only cause confusion.
parent 4f5af43a
...@@ -293,22 +293,7 @@ class TestWorklist(TestWorkflowMixin): ...@@ -293,22 +293,7 @@ class TestWorklist(TestWorkflowMixin):
self.logMessage("Check %s worklist" % user_id) self.logMessage("Check %s worklist" % user_id)
self.loginByUserName(user_id) self.loginByUserName(user_id)
result = workflow_tool.listActions(object=document) result = workflow_tool.listActions(object=document)
self.assertEqual(len(result), 2) self.assertEqual(result, [])
action, = [r for r in result if r["id"] == "onlyjio_validation_workflow"]
self.assertEqual(action["name"], "Validation Workflow")
self.assertTrue(
action["url"].endswith("/portal_workflow/validation_workflow/Base_redirectToWorkflowDocument?workflow_id=validation_workflow"),
action
)
self.assertEqual(action["category"], "object_onlyjio_jump")
action, = [r for r in result if r["id"] == "onlyjio_edit_workflow"]
self.assertEqual(action["name"], "Edit Workflow")
self.assertTrue(
action["url"].endswith("/portal_workflow/edit_workflow/Base_redirectToWorkflowDocument?workflow_id=edit_workflow"),
action
)
self.assertEqual(action["category"], "object_onlyjio_jump")
for role, user_id_list in (('Assignor', ('foo', 'manager')), for role, user_id_list in (('Assignor', ('foo', 'manager')),
('Assignee', ('foo', 'bar'))): ('Assignee', ('foo', 'bar'))):
......
...@@ -612,12 +612,12 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -612,12 +612,12 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['href'], self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) urllib.quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['title'], "Queries") self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries")
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['name'], "jump_query") self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query")
self.assertEqual(result_dict['_links']['portal']['href'], 'urn:jio:get:%s' % document.getPortalObject().getId()) self.assertEqual(result_dict['_links']['portal']['href'], 'urn:jio:get:%s' % document.getPortalObject().getId())
self.assertEqual(result_dict['_links']['portal']['name'], document.getPortalObject().getTitle()) self.assertEqual(result_dict['_links']['portal']['name'], document.getPortalObject().getTitle())
...@@ -985,12 +985,12 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -985,12 +985,12 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['title'], "Custom Action No Dialog")
self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog") self.assertEqual(result_dict['_links']['action_workflow'][0]['name'], "custom_action_no_dialog")
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['href'], self.assertEqual(result_dict['_links']['action_object_jio_jump']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % ( "%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=jump_query" % (
self.portal.absolute_url(), self.portal.absolute_url(),
urllib.quote_plus(document.getRelativeUrl()))) urllib.quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['title'], "Queries") self.assertEqual(result_dict['_links']['action_object_jio_jump']['title'], "Queries")
self.assertEqual(result_dict['_links']['action_object_jio_jump'][0]['name'], "jump_query") self.assertEqual(result_dict['_links']['action_object_jio_jump']['name'], "jump_query")
self.assertEqual(result_dict['_links']['portal']['href'], 'urn:jio:get:%s' % document.getPortalObject().getId()) self.assertEqual(result_dict['_links']['portal']['href'], 'urn:jio:get:%s' % document.getPortalObject().getId())
self.assertEqual(result_dict['_links']['portal']['name'], document.getPortalObject().getTitle()) self.assertEqual(result_dict['_links']['portal']['name'], document.getPortalObject().getTitle())
......
...@@ -446,6 +446,8 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -446,6 +446,8 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if object is not None or info is None: if object is not None or info is None:
info = self._getOAI(object) info = self._getOAI(object)
actions = [] actions = []
portal = self.getPortalObject()
developer_mode_enabled = portal.portal_preferences.getPreferredHtmlStyleDevelopperMode()
if info.object is not None: if info.object is not None:
object_portal_type = info.object.getTypeInfo() object_portal_type = info.object.getTypeInfo()
...@@ -453,19 +455,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -453,19 +455,19 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
for wf_id in object_portal_type.getTypeWorkflowList(): for wf_id in object_portal_type.getTypeWorkflowList():
wf = self._getOb(wf_id, None) wf = self._getOb(wf_id, None)
if wf is not None: if wf is not None:
actions.append({ if developer_mode_enabled:
"id": "onlyjio_%s" % wf.getReference(), actions.append({
"name": wf.getTitle(), "id": "onlyjio_%s" % wf.getReference(),
"url": "%s/Base_redirectToWorkflowDocument?workflow_id=%s" % ( "name": wf.getTitle(),
wf.absolute_url(), "url": "%s/Base_redirectToWorkflowDocument?workflow_id=%s" % (
wf.getId()), wf.absolute_url(),
"icon": None, wf.getId()),
"category": "object_onlyjio_jump", "icon": None,
"priority": 100 "category": "object_onlyjio_jump",
}) "priority": 100
})
actions.extend(wf.listObjectActions(info)) actions.extend(wf.listObjectActions(info))
portal = self.getPortalObject()
portal_url = portal.portal_url() portal_url = portal.portal_url()
def _getWorklistActionList(): def _getWorklistActionList():
worklist_dict = {} worklist_dict = {}
......
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