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]
support_request = portal.support_request_module.newContent(
portal_type='Support Request',
title=title,
resource="service_module/" + resource,
resource=resource,
destination_decision_value=logged_in_user_value,
source_decision_value = project_object.getSourceDecisionValue(),
source_section_value = project_object.getSourceSectionValue(),
......
......@@ -136,7 +136,7 @@
<dictionary>
<item>
<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>
</dictionary>
</pickle>
......
portal = context.getPortalObject()
project = None
if project_id:
project_list = portal.portal_catalog(portal_type="Project", id=project_id, limit=1)
else:
project_list = portal.portal_catalog(portal_type="Project", validation_state="validated", limit=1)
try:
project = project_list[0]
except IndexError:
project = None
project = portal.project_module[project_id]
result = context.SupportRequest_getSupportTypeListFromProjectValue(project)
if json_flag:
from json import dumps
container.REQUEST.RESPONSE.setHeader('content-type', 'application/json')
return dumps(result)
return result
"""Returns the services that can be used on support request for this project.
"""
# /!\ proxy role !
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:
sale_supply_list = portal.portal_catalog(portal_type="Sale Supply", destination_project_uid=project_value.getUid())
for sale_supply in sale_supply_list:
......@@ -8,6 +17,9 @@ if project_value is not None:
for supply_line in sale_supply_line_list:
service = supply_line.getResourceValue()
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):
self.getWebSite().SupportRequestModule_createSupportRequest(
description='<b>Help !!!</b>',
file=None,
# FIXME: resource passed by the UI should be full relative URL
resource='erp5_officejs_support_request_ui_test_service_001',
# resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
title=self.id(),
project='erp5_officejs_support_request_ui_test_project_001',
# FIXME: project passed by the UI should be full relative URL
......@@ -169,9 +167,7 @@ class TestSupportRequestCreateNewSupportRequest(SupportRequestTestCase):
self.getWebSite().SupportRequestModule_createSupportRequest(
description='<b>Look at this file !</b>',
file=FileUpload("the text content"),
# FIXME: resource passed by the UI should be full relative URL
resource='erp5_officejs_support_request_ui_test_service_001',
# resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
resource=self.portal.service_module.erp5_officejs_support_request_ui_test_service_001.getRelativeUrl(),
title=self.id(),
project='erp5_officejs_support_request_ui_test_project_001',
# 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