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
Matevz Golob
erp5
Commits
3dfcdabd
Commit
3dfcdabd
authored
Jan 09, 2018
by
Xiaowu Zhang
Committed by
Tomáš Peterka
Jan 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: check also editable field in proxy form
an editable field may be defined in proxy form
parent
8fdc1a15
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
3 deletions
+66
-3
bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py
...TemplateItem/portal_components/extension.erp5.HalStyle.py
+4
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_aqInner.xml
...ateItem/portal_skins/erp5_hal_json_style/Base_aqInner.xml
+28
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+11
-2
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+23
-0
No files found.
bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py
View file @
3dfcdabd
from
Acquisition
import
aq_self
,
aq_base
from
Acquisition
import
aq_self
,
aq_base
,
aq_inner
def
Base_aqSelf
(
self
):
def
Base_aqSelf
(
self
):
return
aq_self
(
self
)
return
aq_self
(
self
)
...
@@ -6,6 +6,9 @@ def Base_aqSelf(self):
...
@@ -6,6 +6,9 @@ def Base_aqSelf(self):
def
Base_aqBase
(
self
):
def
Base_aqBase
(
self
):
return
aq_base
(
self
)
return
aq_base
(
self
)
def
Base_aqInner
(
self
):
return
aq_inner
(
self
)
def
Field_getSubFieldKeyDict
(
self
,
field
,
field_id
,
key
=
None
):
def
Field_getSubFieldKeyDict
(
self
,
field
,
field_id
,
key
=
None
):
"""XXX"""
"""XXX"""
return
field
.
generate_subfield_key
(
field_id
,
key
=
key
)
return
field
.
generate_subfield_key
(
field_id
,
key
=
key
)
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_aqInner.xml
0 → 100644
View file @
3dfcdabd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
Base_aqInner
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
HalStyle
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_aqInner
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
3dfcdabd
...
@@ -1396,7 +1396,6 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
...
@@ -1396,7 +1396,6 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
if
source_field
is
not
None
and
source_field_meta_type
==
"ListBox"
:
if
source_field
is
not
None
and
source_field_meta_type
==
"ListBox"
:
listbox_field_id
=
source_field
.
id
listbox_field_id
=
source_field
.
id
# XXX Proxy field are not correctly handled in traversed_document of web site
listbox_form
=
getattr
(
traversed_document
,
source_field
.
aq_parent
.
id
)
listbox_form
=
getattr
(
traversed_document
,
source_field
.
aq_parent
.
id
)
# field TALES expression evaluated by Base_getRelatedObjectParameter requires that
# field TALES expression evaluated by Base_getRelatedObjectParameter requires that
...
@@ -1411,6 +1410,16 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
...
@@ -1411,6 +1410,16 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
if
listbox_form
.
has_field
(
field_name
,
include_disabled
=
1
):
if
listbox_form
.
has_field
(
field_name
,
include_disabled
=
1
):
editable_field_dict
[
select
]
=
listbox_form
.
get_field
(
field_name
,
include_disabled
=
1
)
editable_field_dict
[
select
]
=
listbox_form
.
get_field
(
field_name
,
include_disabled
=
1
)
#check if proxyfy
if
source_field
.
meta_type
==
"ProxyField"
:
proxy_listbox_field_id
=
source_field
.
getRecursiveTemplateField
().
id
proxy_form
=
getattr
(
traversed_document
,
source_field
.
getRecursiveTemplateField
().
Base_aqInner
().
aq_parent
.
id
)
for
select
in
select_list
:
#need also get editalbe field from proxy form
proxy_field_name
=
"{}_{}"
.
format
(
proxy_listbox_field_id
,
select
.
replace
(
"."
,
"_"
))
if
proxy_form
.
has_field
(
proxy_field_name
,
include_disabled
=
1
):
editable_field_dict
[
select
]
=
proxy_form
.
get_field
(
proxy_field_name
,
include_disabled
=
1
)
# handle the case when list-scripts are ignoring `limit` - paginate for them
# handle the case when list-scripts are ignoring `limit` - paginate for them
if
limit
is
not
None
and
isinstance
(
limit
,
(
tuple
,
list
)):
if
limit
is
not
None
and
isinstance
(
limit
,
(
tuple
,
list
)):
start
,
num_items
=
map
(
int
,
limit
)
start
,
num_items
=
map
(
int
,
limit
)
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
3dfcdabd
...
@@ -982,6 +982,29 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
...
@@ -982,6 +982,29 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
mode
=
"search"
,
mode
=
"search"
,
default_param_json
=
'eyJcdTAwZWEiOiAiXHUwMGU4In0='
)
default_param_json
=
'eyJcdTAwZWEiOiAiXHUwMGU4In0='
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
simulate
(
'Test_listProducts'
,
'*args, **kwargs'
,
"""
return context.getPortalObject().foo_module.contentValues()
"""
)
@
createIndexedDocument
()
@
changeSkin
(
'Hal'
)
def
test_getHateoas_proxy_listbox_editable_field
(
self
,
**
kw
):
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
proxifyField
({
'listbox'
:
'Base_viewFieldLibrary.my_list_mode_listbox'
})
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
REQUEST
=
fake_request
,
mode
=
"search"
,
local_roles
=
[
"Assignor"
,
"Assignee"
],
list_method
=
'Test_listProducts'
,
select_list
=
[
'id'
,
'title'
,
'creation_date'
,
'modification_date'
],
form_relative_url
=
'portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
)
result_dict
=
json
.
loads
(
result
)
#editalble creation date is defined at proxy form
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'creation_date'
][
'type'
],
'DateTimeField'
)
self
.
assertEqual
(
result_dict
[
'_embedded'
][
'contents'
][
0
][
'modification_date'
][
'type'
],
'DateTimeField'
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
simulate
(
'Test_listObjects'
,
'*args, **kwargs'
,
"""
@
simulate
(
'Test_listObjects'
,
'*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