Commit 66a35a25 authored by Romain Courteaud's avatar Romain Courteaud

erp5_hal_json_style: add traverse_document info

parent 1938c542
......@@ -1328,6 +1328,13 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
last_form_id = None # will point to the previous form so we can obtain previous selection
result_dict['title'] = ensureUTF8(traversed_document.getTranslatedTitle())
result_dict['_links']["traversed_document"] = {
"href": default_document_uri_template % {
"relative_url": getRealRelativeUrl(traversed_document)
},
"name": getRealRelativeUrl(traversed_document),
"title": result_dict['title']
}
# extra_param_json should be base64 encoded JSON at this point
# only for mode == 'form' it is already a dictionary
......
......@@ -381,6 +381,9 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8"))
self.assertEqual(result_dict['_debug'], "root")
@simulate('Base_getRequestUrl', '*args, **kwargs',
......@@ -454,6 +457,9 @@ class TestERP5Document_getHateoas_mode_root(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['traverse']['name'], "Traverse")
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8"))
self.assertEqual(result_dict['default_view'], "view")
self.assertEqual(result_dict['_debug'], "root")
......@@ -530,6 +536,9 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8"))
self.assertEqual(result_dict['_debug'], "traverse")
@simulate('Base_getRequestUrl', '*args, **kwargs',
......@@ -627,6 +636,9 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_links']['type']['name'], document.getPortalType())
self.assertEqual(result_dict['title'].encode("UTF-8"), document.getTitle())
self.assertEqual(result_dict['_links']['traversed_document']['href'], 'urn:jio:get:%s' % document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['name'], document.getRelativeUrl())
self.assertEqual(result_dict['_links']['traversed_document']['title'], document.getTitle().decode("UTF-8"))
self.assertEqual(result_dict['_debug'], "traverse")
# Check embedded form rendering
......
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