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
4cb13be9
Commit
4cb13be9
authored
Jul 31, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: add compatibility with URL columns returning None value
parent
5f3489f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-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
+4
-0
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+38
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
4cb13be9
...
...
@@ -2039,6 +2039,10 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
selection
=
catalog_kw
[
'selection'
],
selection_name
=
catalog_kw
[
'selection_name'
],
column_id
=
select
)
if
url_parameter_dict
is
None
:
# url method want to disable URL in xhtml
# Keep compatibility with this simple case
url_parameter_dict
=
{}
else
:
if
not
is_getListItemUrlDict_calculated
:
# XXX If only available on brains, maybe better to call on aq_self
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
4cb13be9
...
...
@@ -1874,6 +1874,44 @@ return url
# Reset the url_columns of the listbox
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
manage_tales_xmlrpc
(
dict
(
url_columns
=
''
))
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
simulate
(
'Base_getUrl'
,
'url_dict=False, *args, **kwargs'
,
"""
return None
"""
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasDocument_listbox_check_url_column_returning_None
(
self
):
# variation of test_getHateoasDocument_listbox_check_url_column_no_url here the
# "no url" is done by setting `None` in TALES expression, instead of '' that get
# set by formulator `key | value` syntax.
self
.
_makeDocument
()
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
manage_tales_xmlrpc
(
dict
(
url_columns
=
'python: [("title", "Base_getUrl"), ]'
))
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"search"
,
list_method
=
'contentValues'
,
relative_url
=
'foo_module'
,
select_list
=
[
'id'
,
'title'
,
'creation_date'
,
'modification_date'
],
form_relative_url
=
'portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
)
result_dict
=
json
.
loads
(
result
)
# Test the listbox_uid parameter
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'listbox_uid:list'
][
'key'
],
'listbox_uid:list'
)
# Test the URL value
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'url_value'
],
{})
# Test if the value of the column is with right key
self
.
assertTrue
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'title'
][
'default'
])
# Reset the url_columns of the listbox
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
manage_tales_xmlrpc
(
dict
(
url_columns
=
''
))
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
...
...
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