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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
c21bef69
Commit
c21bef69
authored
Nov 30, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Do not calculate field default when rendering a listbox cell
parent
66b6dd09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+8
-6
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
c21bef69
...
...
@@ -559,7 +559,7 @@ def getFieldDefault(form, field, key, value=None):
return
value
def
renderField
(
traversed_document
,
field
,
form
,
value
=
None
,
meta_type
=
None
,
key
=
None
,
key_prefix
=
None
,
selection_params
=
None
,
request_field
=
True
):
def
renderField
(
traversed_document
,
field
,
form
,
value
=
MARKER
,
meta_type
=
None
,
key
=
None
,
key_prefix
=
None
,
selection_params
=
None
,
request_field
=
True
):
"""Extract important field's attributes into `result` dictionary."""
if
selection_params
is
None
:
selection_params
=
{}
...
...
@@ -593,10 +593,12 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
if
"Field"
in
meta_type
:
# fields have default value and can be required (unlike boxes)
result
.
update
({
"required"
:
field
.
get_value
(
"required"
)
if
field
.
has_value
(
"required"
)
else
None
,
"default"
:
getFieldDefault
(
form
,
field
,
key
,
value
),
})
result
[
"required"
]
=
field
.
get_value
(
"required"
)
if
field
.
has_value
(
"required"
)
else
None
if
value
is
MARKER
:
result
[
"default"
]
=
getFieldDefault
(
form
,
field
,
key
)
else
:
# No need to calculate the field value if provided (used in Listbox)
result
[
"default"
]
=
value
# start the actual "switch" on field's meta_type here
if
meta_type
in
(
"ListField"
,
"RadioField"
,
"ParallelListField"
,
"MultiListField"
):
...
...
@@ -1936,7 +1938,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
REQUEST
.
set
(
'cell'
,
search_result
)
for
select
in
select_list
:
contents_item
[
select
]
=
{}
default_field_value
=
None
default_field_value
=
MARKER
# every `select` can have a template field or be just a exotic getter for a value
if
editable_field_dict
.
has_key
(
select
):
# cell has a Form Field template thus render it using the field
...
...
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