Commit 26d8e3b3 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: only display worklists involving Support Requests

Because this was displaying all worklists from ticket_worklist, which is
also used for all tickets (including for example Campaigns) and that
displaying other kind of tickets that Support Request is not supported
on this app, we should filter the worklists to display only support requests.

/reviewed-on nexedi/erp5!808
parent 2c56ad8a
"""Returns the worklists queries for ticket workflow, as a mapping where the key is the worklist ID and the value a JIO query.
If `portal_type` is provided, only return worklists that apply for this portal type.
This script has proxy role, as only manager can access workflow configuration.
"""
from Products.ERP5Type.Message import translateString
......@@ -11,6 +13,11 @@ workflow = portal.portal_workflow.ticket_workflow
workflow_state_var = workflow.variables.getStateVar()
for worklist in workflow.worklists.objectValues():
if portal_type \
and 'portal_type' in worklist.getVarMatchKeys() \
and portal_type not in worklist.getVarMatch('portal_type'):
continue
query_list = [{
'type': 'complex',
'operator': 'OR',
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>portal_type=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -3,8 +3,9 @@ from Products.ERP5Type.Message import translateString
import json
portal = context.getPortalObject()
worklist_query_dict = portal.ERP5Site_getTicketWorkflowWorklistInfoDict()
worklist_query_dict = portal.ERP5Site_getTicketWorkflowWorklistInfoDict(
portal_type='Support Request'
)
# Query portal actions to get the worklist count and
# extend this information with the query from our helper script.
......@@ -15,7 +16,9 @@ worklist_action_list = [
'query': worklist_query_dict[action['worklist_id']],
}
for action in portal.portal_actions.listFilteredActionsFor(context)['global']
if action['category'] == 'global' and action.get('workflow_id') == 'ticket_workflow'
if action['category'] == 'global'
and action.get('workflow_id') == 'ticket_workflow'
and action.get('worklist_id') in worklist_query_dict
]
return json.dumps(worklist_action_list)
......@@ -61,6 +61,11 @@
<td>//section[@class="document_list"]//li/a[contains(text(), "Suspended Support Requests")]/span[text() = "1"]</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//section[@class="document_list"]//li/a[contains(text(), "Campaign")]/span[text() = "1"]</td>
<td></td>
</tr>
<!-- clicking on one worklist open the module -->
<tr>
......
......@@ -52,4 +52,12 @@ portal.support_request_module.newContent(
source_project_value=portal.project_module.erp5_officejs_support_request_ui_test_project_001,
).validate()
# create a campaign that should not appear in this worklist
if portal.portal_workflow.ticket_workflow.worklists.get('0A_draft_campaign_list', None) is None:
raise ValueError('Without this worklist, tests have to be updated.')
portal.campaign_module.newContent(
portal_type='Campaign',
title="Should not appear in support request app",
)
return "Done."
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