Commit 6c56e746 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py2

parents 354cbfd4 c1b70e3d
......@@ -997,7 +997,7 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
# ... so we can do some magic with it (especially embedded listbox if exists)!
try:
if last_form_id:
last_form = getattr(context, last_form_id)
last_form = getattr(traversed_document, last_form_id)
last_listbox = last_form.Base_getListbox()
except AttributeError:
pass
......
......@@ -1076,6 +1076,28 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertIn("dialog_id", field_names)
# no need for dialog_method because that one is hardcoded in javascript
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@changeSkin('Hal')
def test_getHateoasDocument_last_form_rendering_context(self):
self.portal.foo_module.FooModule_viewFooList.listbox.manage_tales_xmlrpc(dict(selection_name='python: "foo_selection" if here.getPortalType()=="Foo Module" else "wrong_selection"'))
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="traverse",
relative_url=self.portal.foo_module.getRelativeUrl(),
view="create_a_document",
extra_param_json = {"form_id": "FooModule_viewFooList"}
)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_embedded']['_view']['selection_name']['default'], 'foo_selection')
self.portal.foo_module.FooModule_viewFooList.listbox.manage_tales_xmlrpc(dict(selection_name=''))
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
......
......@@ -46,6 +46,5 @@ if listbox:
for group in ('bottom', 'center', 'left', 'right'):
for field in form.get_fields_in_group(group):
if (isListBox(field) and
not field.get_value('hidden') and
field.get_value('enabled')):
not field.get_value('hidden')):
return field
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