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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
f99dadff
Commit
f99dadff
authored
Dec 28, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: ensure select list result can be sent as JSON
parent
486c7327
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+1
-1
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+27
-2
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
f99dadff
...
...
@@ -2017,7 +2017,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
elif
isinstance
(
default_field_value
,
datetime
.
date
):
default_field_value
=
formatdate
(
time
.
mktime
(
default_field_value
.
timetuple
()))
contents_item
[
select
]
=
default_field_value
contents_item
[
select
]
=
ensureUTF8
(
default_field_value
)
else
:
# If the contents_item has field rendering in it, better is to add an
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
f99dadff
...
...
@@ -81,9 +81,9 @@ def createIndexedDocument(quantity=1):
def
decorator
(
func
):
def
wrapped
(
self
,
*
args
,
**
kwargs
):
wipeFolder
(
self
.
portal
.
foo_module
)
if
quantity
<
=
1
:
if
quantity
=
=
1
:
kwargs
.
update
(
document
=
self
.
_makeDocument
())
el
se
:
el
if
quantity
>
1
:
kwargs
.
update
(
document_list
=
[
self
.
_makeDocument
()
for
_
in
range
(
quantity
)])
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
...
...
@@ -2332,6 +2332,31 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'selection_name'
],
selection_name
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'_view'
][
'listbox'
][
'checked_uid_list'
],
[
9876
,
1234
])
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
createIndexedDocument
(
quantity
=
1
)
@
changeSkin
(
'Hal'
)
def
test_getHateoas_property_corrupted_encoding
(
self
,
document
):
# this sequence of bytes does not encode to UTF-8
document
.
setTitle
(
'
\
xe9
\
xcf
\
xf3
\
xaf
'
)
# self.tic()
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"search"
,
query
=
'uid:"%s"'
%
document
.
getUid
(),
select_list
=
[
'title'
],
)
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
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
1
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
"title"
],
u'
\
ufffd
\
ufffd
\
ufffd
'
)
class
TestERP5Person_getHateoas_mode_search
(
ERP5HALJSONStyleSkinsMixin
):
"""Test HAL_JSON operations on cataloged Persons and other allowed content types of Person Module."""
...
...
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