Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
dabf767a
Commit
dabf767a
authored
Sep 22, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: add traverse_document info
parent
00b4f4db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+7
-0
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+12
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
dabf767a
...
...
@@ -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
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
dabf767a
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment