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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tomáš Peterka
erp5
Commits
6cf2326c
Commit
6cf2326c
authored
Nov 08, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json_style] Add test for incosistent rendering of search-enabled gadgets
parent
5619e751
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+5
-5
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+36
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
6cf2326c
...
...
@@ -402,6 +402,9 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
for
name
,
title
in
(
selection_params
.
get
(
'selection_sort_order'
,
[])
or
field
.
get_value
(
"sort_columns"
))
if
sql_catalog
.
isValidColumn
(
name
)]
or
search_column_list
# portal_type list can be overriden by selection too
# since it can be intentionally empty we don't override with non-empty field value
portal_type_list
=
selection_params
.
get
(
"portal_type"
,
field
.
get_value
(
'portal_types'
))
# requirement: get only sortable/searchable columns which are already displayed in listbox
# see https://lab.nexedi.com/nexedi/erp5/blob/HEAD/product/ERP5Form/ListBox.py#L1004
...
...
@@ -410,11 +413,9 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
default_params
=
dict
(
field
.
get_value
(
'default_params'
))
# default_params is a list of tuples
default_params
[
'ignore_unknown_columns'
]
=
True
# we abandoned Selections in RJS thus we mix selection query parameters into
# listbox's default parameters
if
selection_params
is
not
None
:
default_params
.
update
(
selection_params
)
default_params
.
update
(
selection_params
)
lines
=
field
.
get_value
(
'lines'
)
list_method_name
=
traversed_document
.
Listbox_getListMethodName
(
field
)
...
...
@@ -423,9 +424,8 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
# in that case we prefer non_empty version
list_method_query_dict
=
default_params
.
copy
()
if
not
list_method_query_dict
.
get
(
"portal_type"
,
[]):
list_method_query_dict
[
"portal_type"
]
=
[
x
for
x
,
_
in
field
.
get_value
(
'portal_types'
)
]
list_method_query_dict
[
"portal_type"
]
=
[
x
for
x
,
_
in
portal_type_list
]
list_method_custom
=
None
portal_type_list
=
list_method_query_dict
[
"portal_type"
]
# Search for non-editable documents - all reports goes here
# Reports have custom search scripts which wants parameters from the form
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
6cf2326c
...
...
@@ -630,6 +630,42 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'_actions'
][
'put'
][
'method'
],
'POST'
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasDocument_listbox_vs_relation_inconsistency
(
self
):
"""Purpose of this test is to point to inconsistencies in search-enabled field rendering.
ListBox gets its Portal Types in `portal_type` as list of tuples whether
Relation Input receives `portal_types` and `translated_portal_types`
"""
document
=
self
.
_makeDocument
()
# Drop editable permission
document
.
manage_permission
(
'Modify portal content'
,
[],
0
)
document
.
Foo_view
.
listbox
.
ListBox_setPropertyList
(
field_title
=
'Foo Lines'
,
field_list_method
=
'objectValues'
,
field_portal_types
=
'Foo Line | Foo Line'
,
)
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"
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
status
,
200
)
self
.
assertEquals
(
fake_request
.
RESPONSE
.
getHeader
(
'Content-Type'
),
"application/hal+json"
)
result_dict
=
json
.
loads
(
result
)
# ListBox rendering of allowed Portal Types
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'portal_type'
],
[[
'Foo Line'
,
'Foo Line'
]])
# Relation Input rendering of allowed Portal Types
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'my_foo_category_title'
][
'portal_types'
],
[
'Category'
])
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'my_foo_category_title'
][
'translated_portal_types'
],
[
'Category'
])
@
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