Commit 3bba8c31 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_hal_json_style] Listbox: propagate checked uid list

parent 83022970
......@@ -755,7 +755,9 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k
list_method_query_dict,
ignore_unknown_columns=True).asSearchTextExpression(sql_catalog)})},
"domain_root_list": [(x, Base_translateString(y)) for x, y in field.get_value("domain_root_list")],
"selection_name": field.get_value('selection_name')
"selection_name": field.get_value('selection_name'),
"checked_uid_list": portal.portal_selections.getSelectionCheckedUidsFor(field.get_value('selection_name'))
})
result["domain_dict"] = getDomainSelection([x[0] for x in result["domain_root_list"]])
......
......@@ -650,6 +650,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['listbox']['key'], 'field_listbox')
self.assertEqual(result_dict['_embedded']['_view']['listbox']['title'], 'Foo Lines')
self.assertEqual(result_dict['_embedded']['_view']['listbox']['selection_name'], 'foo_selection')
self.assertEqual(result_dict['_embedded']['_view']['listbox']['checked_uid_list'], [])
self.assertEqual(result_dict['_embedded']['_view']['listbox']['lines'], 3)
self.assertEqual(result_dict['_embedded']['_view']['listbox']['editable'], 1)
self.assertEqual(result_dict['_embedded']['_view']['listbox']['show_anchor'], 0)
......@@ -1177,6 +1178,7 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['key'], 'x1_listbox')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['title'], 'Workflow History')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['selection_name'], 'base_workflow_history_selection')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['checked_uid_list'], [])
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['lines'], 15)
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['editable'], 1)
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['listbox']['show_anchor'], 0)
......@@ -2189,6 +2191,31 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
{'foo_category': ('portal_categories', 'foo_category/a/a2'),
'foo_domain': ('portal_domains', 'foo_domain/a/a1')})
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoas_selection_checked_uid_compatibility(self):
document = self._makeDocument()
selection_tool = self.portal.portal_selections
selection_name = self.portal.foo_module.Foo_view.listbox.get_value('selection_name')
selection_tool.setSelectionFor(selection_name, Selection(selection_name))
selection_tool.setSelectionCheckedUidsFor(selection_name, [9876, 1234])
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request, mode="traverse", relative_url=document.getRelativeUrl(), view="view")
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"})
self.assertEqual(result_dict['_embedded']['_view']['listbox']['selection_name'], selection_name)
self.assertEqual(result_dict['_embedded']['_view']['listbox']['checked_uid_list'], [9876, 1234])
class TestERP5Person_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
"""Test HAL_JSON operations on cataloged Persons and other allowed content types of Person Module."""
......
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