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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
erp5
Commits
f402de4e
Commit
f402de4e
authored
Jul 08, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Do not return action if no script is defined
parent
c3f0585c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+2
-1
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+34
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
f402de4e
...
...
@@ -850,7 +850,8 @@ def renderForm(traversed_document, form, response_dict, key_prefix=None, selecti
action_to_call
=
"Base_callDialogMethod"
else
:
action_to_call
=
form
.
action
if
(
action_to_call
==
'Base_edit'
)
and
(
not
portal
.
portal_membership
.
checkPermission
(
'Modify portal content'
,
traversed_document
)):
if
(
not
action_to_call
)
or
\
((
action_to_call
==
'Base_edit'
)
and
(
not
portal
.
portal_membership
.
checkPermission
(
'Modify portal content'
,
traversed_document
))):
# prevent allowing editing if user doesn't have permission
include_action
=
False
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
f402de4e
...
...
@@ -1188,6 +1188,40 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['
group_list
'][0][1][0], ['
my_id
', {'
meta_type
': '
ProxyField
'}])
self.assertEqual(result_dict['
_debug
'], "traverse")
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
args
,
**
kwargs
',
'
return
"application/hal+json"')
@changeSkin('
Hal
')
def test_getHateoasForm_no_pt_action(self):
document = self._makeDocument()
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_simple_graph"
)
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['
title
'].encode('
UTF
-
8
'), document.getTitle())
self.assertEqual(
result_dict['
_embedded
']['
_view
']['
_embedded
']['
form_definition
']['
pt
'],
'
form_view
'
)
self.assertEqual(
result_dict['
_embedded
']['
_view
']['
_embedded
']['
form_definition
']['
action
'],
''
)
self.assertTrue('
_actions
' not in result_dict['
_embedded
']['
_view
'])
class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
...
...
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