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
0f26fa07
Commit
0f26fa07
authored
Jul 21, 2017
by
Tomáš Peterka
Committed by
Tomáš Peterka
Jul 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Refactor part of ERP5Document_getHateoas.py to be more readable
parent
42fbcc78
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
45 deletions
+25
-45
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+25
-45
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
0f26fa07
...
@@ -113,7 +113,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
...
@@ -113,7 +113,7 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
"required"
:
field
.
get_value
(
"required"
),
"required"
:
field
.
get_value
(
"required"
),
# XXX Message can not be converted to json as is
# XXX Message can not be converted to json as is
"items"
:
field
.
get_value
(
"items"
),
"items"
:
field
.
get_value
(
"items"
),
"first_item"
:
field
.
get_value
(
"first_item"
)
"first_item"
:
field
.
get_value
(
"first_item"
)
,
}
}
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
elif
meta_type
==
"RadioField"
:
elif
meta_type
==
"RadioField"
:
...
@@ -342,48 +342,30 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
...
@@ -342,48 +342,30 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
}
}
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
result
[
"default"
]
=
getFieldDefault
(
traversed_document
,
field
,
result
[
"key"
],
value
)
elif
meta_type
==
"ListBox"
:
elif
meta_type
==
"ListBox"
:
# XXX Not implemented
"""Display list of objects with optional search/sort capabilities on columns from catalog."""
column_list
=
[]
_translate
=
Base_translateString
for
tmp
in
field
.
get_value
(
"columns"
):
column_list
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"columns"
)]
editable_column_list
=
[]
editable_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"editable_columns"
)]
for
tmp
in
field
.
get_value
(
'editable_columns'
):
catalog_column_list
=
[(
name
,
title
)
editable_column_list
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
for
name
,
title
in
column_list
if
sql_catalog
.
isValidColumn
(
name
)]
sort_column_list_tmp
=
[]
# try to get specified searchable columns and fail back to all searchable columns
for
tmp
in
field
.
get_value
(
'sort_columns'
):
search_column_list
=
[(
name
,
_translate
(
title
))
sort_column_list_tmp
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
for
name
,
title
in
field
.
get_value
(
"search_columns"
)
if
sql_catalog
.
isValidColumn
(
name
)]
or
catalog_column_list
search_column_list_tmp
=
[]
for
tmp
in
field
.
get_value
(
'search_columns'
):
# try to get specified sortable columns and fail back to searchable fields
search_column_list_tmp
.
append
((
tmp
[
0
],
Base_translateString
(
tmp
[
1
])))
sort_column_list
=
[(
name
,
_translate
(
title
))
for
name
,
title
in
field
.
get_value
(
"sort_columns"
)
sort_column_list
=
[]
if
sql_catalog
.
isValidColumn
(
name
)]
or
search_column_list
search_column_list
=
[]
# requirement: get only sortable/searchable columns which are already displayed in listbox
#only get sortable&searchable column which is already displayed in listbox
# see https://lab.nexedi.com/nexedi/erp5/blob/HEAD/product/ERP5Form/ListBox.py#L1004
#see https://lab.nexedi.com/nexedi/erp5/blob/HEAD/product/ERP5Form/ListBox.py#L1004
# implemented in javascript in the end
# see https://lab.nexedi.com/nexedi/erp5/blob/master/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.js#L163
if
search_column_list_tmp
:
search_column_list
=
search_column_list_tmp
else
:
for
grain
in
column_list
:
if
sql_catalog
.
isValidColumn
(
grain
[
0
]):
search_column_list
.
append
(
grain
)
if
sort_column_list_tmp
:
sort_column_list
=
sort_column_list_tmp
else
:
sort_column_list
=
search_column_list
# XXX
# list_method = getattr(traversed_document, traversed_document.Listbox_getListMethodName(field))
# portal_types = [x[1] for x in field.get_value('portal_types')]
portal_types
=
field
.
get_value
(
'portal_types'
)
portal_types
=
field
.
get_value
(
'portal_types'
)
default_params
=
dict
(
field
.
get_value
(
'default_params'
))
default_params
=
dict
(
field
.
get_value
(
'default_params'
))
default_params
[
'ignore_unknown_columns'
]
=
True
default_params
[
'ignore_unknown_columns'
]
=
True
...
@@ -445,19 +427,17 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
...
@@ -445,19 +427,17 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
result
=
{
result
=
{
"type"
:
meta_type
,
"type"
:
meta_type
,
"editable"
:
field
.
get_value
(
"editable"
),
"editable"
:
field
.
get_value
(
"editable"
),
# "column_list": [x[1] for x in columns],
"column_list"
:
column_list
,
"column_list"
:
column_list
,
"search_column_list"
:
search_column_list
,
"search_column_list"
:
search_column_list
,
"sort_column_list"
:
sort_column_list
,
"sort_column_list"
:
sort_column_list
,
"editable_column_list"
:
editable_column_list
,
"editable_column_list"
:
editable_column_list
,
"show_anchor"
:
field
.
get_value
(
"anchor"
),
"show_anchor"
:
field
.
get_value
(
"anchor"
),
# "line_list": line_list,
"title"
:
Base_translateString
(
field
.
get_value
(
"title"
)),
"title"
:
Base_translateString
(
field
.
get_value
(
"title"
)),
"key"
:
key
,
"key"
:
key
,
"portal_type"
:
portal_types
,
"portal_type"
:
portal_types
,
"lines"
:
lines
,
"lines"
:
lines
,
"default_params"
:
default_params
,
"default_params"
:
default_params
,
"list_method"
:
list_method_name
"list_method"
:
list_method_name
,
}
}
if
(
list_method_custom
is
not
None
):
if
(
list_method_custom
is
not
None
):
result
[
"list_method_template"
]
=
list_method_custom
result
[
"list_method_template"
]
=
list_method_custom
...
...
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