Commit e74504d0 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request_ui: allow all SR services when project does not define supplies

Also use relative URL for service, not just the service ID (this is API
breaking change, but the javascript part should not have this cached)
parent ac3e90ac
...@@ -8,7 +8,7 @@ project_object = portal.project_module[project] ...@@ -8,7 +8,7 @@ project_object = portal.project_module[project]
support_request = portal.support_request_module.newContent( support_request = portal.support_request_module.newContent(
portal_type='Support Request', portal_type='Support Request',
title=title, title=title,
resource="service_module/" + resource, resource=resource,
destination_decision_value=logged_in_user_value, destination_decision_value=logged_in_user_value,
source_decision_value = project_object.getSourceDecisionValue(), source_decision_value = project_object.getSourceDecisionValue(),
source_section_value = project_object.getSourceSectionValue(), source_section_value = project_object.getSourceSectionValue(),
......
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: here.SupportRequest_getSupportTypeList(request.get("field_your_project", None)) or [(\'\', \'\')]</string> </value> <value> <string>python: context.SupportRequest_getSupportTypeList(request.get("your_project", None))</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
portal = context.getPortalObject() portal = context.getPortalObject()
project = None
if project_id: if project_id:
project_list = portal.portal_catalog(portal_type="Project", id=project_id, limit=1) project = portal.project_module[project_id]
else:
project_list = portal.portal_catalog(portal_type="Project", validation_state="validated", limit=1)
try:
project = project_list[0]
except IndexError:
project = None
result = context.SupportRequest_getSupportTypeListFromProjectValue(project) result = context.SupportRequest_getSupportTypeListFromProjectValue(project)
if json_flag: if json_flag:
from json import dumps from json import dumps
container.REQUEST.RESPONSE.setHeader('content-type', 'application/json')
return dumps(result) return dumps(result)
return result return result
"""Returns the services that can be used on support request for this project.
"""
# /!\ proxy role ! # /!\ proxy role !
portal = context.getPortalObject() portal = context.getPortalObject()
result = [] item_list = portal.Ticket_getResourceItemList(
portal_type='Support Request',
include_context=False,
)
allowed_resource_relative_url_set = set([])
# if this project has supplies, only allow projects from the supplies.
if project_value is not None: if project_value is not None:
sale_supply_list = portal.portal_catalog(portal_type="Sale Supply", destination_project_uid=project_value.getUid()) sale_supply_list = portal.portal_catalog(portal_type="Sale Supply", destination_project_uid=project_value.getUid())
for sale_supply in sale_supply_list: for sale_supply in sale_supply_list:
...@@ -8,6 +17,9 @@ if project_value is not None: ...@@ -8,6 +17,9 @@ if project_value is not None:
for supply_line in sale_supply_line_list: for supply_line in sale_supply_line_list:
service = supply_line.getResourceValue() service = supply_line.getResourceValue()
if service is not None: if service is not None:
result.append((service.getTitle(), service.getId())) allowed_resource_relative_url_set.add(service.getRelativeUrl())
if allowed_resource_relative_url_set:
return [('', '')] + [item for item in item_list if item[1] in allowed_resource_relative_url_set]
return result # otherwise return all support request services
return item_list
...@@ -98,9 +98,7 @@ class TestSupportRequestCreateNewSupportRequest(SupportRequestTestCase): ...@@ -98,9 +98,7 @@ class TestSupportRequestCreateNewSupportRequest(SupportRequestTestCase):
self.getWebSite().SupportRequestModule_createSupportRequest( self.getWebSite().SupportRequestModule_createSupportRequest(
description='<b>Help !!!</b>', description='<b>Help !!!</b>',
file=None, file=None,
# FIXME: resource passed by the UI should be full relative URL resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
resource='erp5_officejs_support_request_ui_test_service_001',
# resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
title=self.id(), title=self.id(),
project='erp5_officejs_support_request_ui_test_project_001', project='erp5_officejs_support_request_ui_test_project_001',
# FIXME: project passed by the UI should be full relative URL # FIXME: project passed by the UI should be full relative URL
...@@ -169,9 +167,7 @@ class TestSupportRequestCreateNewSupportRequest(SupportRequestTestCase): ...@@ -169,9 +167,7 @@ class TestSupportRequestCreateNewSupportRequest(SupportRequestTestCase):
self.getWebSite().SupportRequestModule_createSupportRequest( self.getWebSite().SupportRequestModule_createSupportRequest(
description='<b>Look at this file !</b>', description='<b>Look at this file !</b>',
file=FileUpload("the text content"), file=FileUpload("the text content"),
# FIXME: resource passed by the UI should be full relative URL resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
resource='erp5_officejs_support_request_ui_test_service_001',
# resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
title=self.id(), title=self.id(),
project='erp5_officejs_support_request_ui_test_project_001', project='erp5_officejs_support_request_ui_test_project_001',
# FIXME: project passed by the UI should be full relative URL # FIXME: project passed by the UI should be full relative 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