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
alecs_myu
erp5
Commits
ece05ce9
Commit
ece05ce9
authored
Mar 09, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp_hal_json_style]: count_method should not fail if it is empty or invalid
parent
540935d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+17
-4
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
ece05ce9
...
...
@@ -1926,16 +1926,29 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
if
source_field
is
not
None
and
source_field_meta_type
==
"ListBox"
:
# Trigger count method if exist
# XXX No need to count if no pagination
count_method
=
source_field
.
get_value
(
'count_method'
)
if
count_method
!=
""
and
count_method
.
getMethodName
()
!=
list_method
:
count_method
=
source_field
.
get_value
(
'count_method'
)
or
None
count_method_name
=
count_method
.
getMethodName
()
if
count_method
is
not
None
else
""
# Only try to get count method results in case method name exists, in all
# other cases, just pass.
if
count_method_name
!=
""
and
count_method_name
!=
list_method
:
count_kw
=
dict
(
catalog_kw
)
# Drop not needed parameters
count_kw
.
pop
(
'selection'
,
None
)
count_kw
.
pop
(
'selection_name'
,
None
)
count_kw
.
pop
(
"sort_on"
,
None
)
count_kw
.
pop
(
"limit"
,
None
)
count_method_result
=
getattr
(
traversed_document
,
count_method
.
getMethodName
())(
REQUEST
=
REQUEST
,
**
count_kw
)
result_dict
[
'_embedded'
][
'count'
]
=
ensureSerializable
(
count_method_result
[
0
][
0
])
try
:
count_method
=
getattr
(
traversed_document
,
count_method_name
)
count_method_result
=
count_method
(
REQUEST
=
REQUEST
,
**
count_kw
)
result_dict
[
'_embedded'
][
'count'
]
=
ensureSerializable
(
count_method_result
[
0
][
0
])
except
AttributeError
as
error
:
# In case there is no count_method or some invalid mehtod, instead of
# raising error and breaking the view, its better to log on as warning
# and just pass. This also ensures we have compatibilty with how old
# UI behave in these cases.
log
(
'Invalid count method %s'
%
error
,
level
=
800
)
pass
contents_stat_list
=
[]
# in case the search was issued by listbox we can provide results of
...
...
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