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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
c4f60ee3
Commit
c4f60ee3
authored
Sep 20, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! Formulator: prepare DateTimeField's sub_form dynamically.
parent
9ceca751
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
14 deletions
+29
-14
product/ERP5Form/ProxyField.py
product/ERP5Form/ProxyField.py
+2
-4
product/ERP5Form/tests/testFields.py
product/ERP5Form/tests/testFields.py
+20
-4
product/Formulator/Field.py
product/Formulator/Field.py
+3
-3
product/Formulator/StandardFields.py
product/Formulator/StandardFields.py
+4
-3
No files found.
product/ERP5Form/ProxyField.py
View file @
c4f60ee3
...
@@ -493,10 +493,8 @@ class ProxyField(ZMIField):
...
@@ -493,10 +493,8 @@ class ProxyField(ZMIField):
field
=
template_field
field
=
template_field
return
template_field
return
template_field
def
_aq_dynamic
(
self
,
name
):
def
_get_sub_form
(
self
):
if
name
==
'sub_form'
:
return
self
.
getTemplateField
().
_get_sub_form
(
field
=
self
)
return
self
.
getTemplateField
().
sub_form
return
None
security
.
declareProtected
(
'Access contents information'
,
security
.
declareProtected
(
'Access contents information'
,
'is_delegated'
)
'is_delegated'
)
...
...
product/ERP5Form/tests/testFields.py
View file @
c4f60ee3
...
@@ -764,15 +764,31 @@ class TestProxyField(ERP5TypeTestCase):
...
@@ -764,15 +764,31 @@ class TestProxyField(ERP5TypeTestCase):
'my_date'
,
'Date'
,
'ProxyField'
)
'my_date'
,
'Date'
,
'ProxyField'
)
proxy_field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
proxy_field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
field_id
=
'my_date'
,))
field_id
=
'my_date'
,))
self
.
assertTrue
(
hasattr
(
proxy_field
,
'sub_form'
))
self
.
assertTrue
(
hasattr
(
proxy_field
,
'
_get_
sub_form'
))
self
.
assertEqual
(
proxy_field
.
sub_form
.
render
(),
self
.
assertEqual
(
proxy_field
.
_get_sub_form
()
.
render
(),
original_field
.
sub_form
.
render
())
original_field
.
_get_sub_form
()
.
render
())
# we can render
# we can render
proxy_field
.
render
()
proxy_field
.
render
()
# and validate
# and validate
self
.
container
.
Base_view
.
validate_all_to_request
(
self
.
portal
.
REQUEST
)
self
.
container
.
Base_view
.
validate_all_to_request
(
self
.
portal
.
REQUEST
)
# change style in the original field
original_field
.
manage_edit_xmlrpc
(
dict
(
input_style
=
'number'
))
self
.
assertTrue
(
'type="number"'
in
original_field
.
render
())
self
.
assertTrue
(
'type="number"'
in
proxy_field
.
render
())
# override style in the proxy field
original_field
.
manage_edit_xmlrpc
(
dict
(
input_style
=
'text'
))
proxy_field
.
_surcharged_edit
({
'input_style'
:
'number'
},
[
'input_style'
])
self
.
assertTrue
(
'type="text"'
in
original_field
.
render
())
self
.
assertTrue
(
'type="number"'
in
proxy_field
.
render
())
# unproxify the proxy field
self
.
container
.
Base_view
.
unProxifyField
({
'my_date'
:
'on'
})
unproxified_field
=
self
.
container
.
Base_view
.
my_date
self
.
assertTrue
(
'type="number"'
in
unproxified_field
.
render
())
def
test_manage_edit_surcharged_xmlrpc
(
self
):
def
test_manage_edit_surcharged_xmlrpc
(
self
):
# manage_edit_surcharged_xmlrpc is a method to edit proxyfields
# manage_edit_surcharged_xmlrpc is a method to edit proxyfields
# programmatically
# programmatically
...
@@ -943,7 +959,7 @@ class TestFieldValueCache(ERP5TypeTestCase):
...
@@ -943,7 +959,7 @@ class TestFieldValueCache(ERP5TypeTestCase):
addField
(
DateTimeField
(
'datetime_field'
))
addField
(
DateTimeField
(
'datetime_field'
))
form
.
datetime_field
.
_p_oid
=
makeDummyOid
()
form
.
datetime_field
.
_p_oid
=
makeDummyOid
()
form
.
datetime_field
.
_edit
(
dict
(
input_style
=
'list'
))
form
.
datetime_field
.
_edit
(
dict
(
input_style
=
'list'
))
for
i
in
form
.
datetime_field
.
sub_form
.
fields
.
values
():
for
i
in
form
.
datetime_field
.
_get_sub_form
()
.
fields
.
values
():
i
.
_p_oid
=
makeDummyOid
()
i
.
_p_oid
=
makeDummyOid
()
def
test_method_field
(
self
):
def
test_method_field
(
self
):
...
...
product/Formulator/Field.py
View file @
c4f60ee3
...
@@ -403,7 +403,7 @@ class Field:
...
@@ -403,7 +403,7 @@ class Field:
a form. Works like render() but for sub field.
a form. Works like render() but for sub field.
Added key parameter for ERP5 in order to be compatible with listbox/matrixbox
Added key parameter for ERP5 in order to be compatible with listbox/matrixbox
"""
"""
return
self
.
sub_form
.
get_field
(
id
).
_render_helper
(
return
self
.
_get_sub_form
()
.
get_field
(
id
).
_render_helper
(
self
.
generate_subfield_key
(
id
,
key
=
key
),
value
,
REQUEST
,
render_prefix
)
self
.
generate_subfield_key
(
id
,
key
=
key
),
value
,
REQUEST
,
render_prefix
)
security
.
declareProtected
(
'View'
,
'render_sub_field_from_request'
)
security
.
declareProtected
(
'View'
,
'render_sub_field_from_request'
)
...
@@ -411,7 +411,7 @@ class Field:
...
@@ -411,7 +411,7 @@ class Field:
"""Convenience method; render the field widget from REQUEST
"""Convenience method; render the field widget from REQUEST
(unvalidated data), or default if no raw data is found.
(unvalidated data), or default if no raw data is found.
"""
"""
return
self
.
sub_form
.
get_field
(
id
).
_render_helper
(
return
self
.
_get_sub_form
()
.
get_field
(
id
).
_render_helper
(
self
.
generate_subfield_key
(
id
),
None
,
REQUEST
)
self
.
generate_subfield_key
(
id
),
None
,
REQUEST
)
security
.
declarePrivate
(
'_validate_helper'
)
security
.
declarePrivate
(
'_validate_helper'
)
...
@@ -441,7 +441,7 @@ class Field:
...
@@ -441,7 +441,7 @@ class Field:
def
validate_sub_field
(
self
,
id
,
REQUEST
,
key
=
None
):
def
validate_sub_field
(
self
,
id
,
REQUEST
,
key
=
None
):
"""Validates a subfield (as part of field validation).
"""Validates a subfield (as part of field validation).
"""
"""
return
self
.
sub_form
.
get_field
(
id
).
_validate_helper
(
return
self
.
_get_sub_form
()
.
get_field
(
id
).
_validate_helper
(
self
.
generate_subfield_key
(
id
,
validation
=
1
,
key
=
key
),
REQUEST
)
self
.
generate_subfield_key
(
id
,
validation
=
1
,
key
=
key
),
REQUEST
)
def
PrincipiaSearchSource
(
self
):
def
PrincipiaSearchSource
(
self
):
...
...
product/Formulator/StandardFields.py
View file @
c4f60ee3
...
@@ -127,9 +127,10 @@ class DateTimeField(ZMIField):
...
@@ -127,9 +127,10 @@ class DateTimeField(ZMIField):
widget
=
Widget
.
DateTimeWidgetInstance
widget
=
Widget
.
DateTimeWidgetInstance
validator
=
Validator
.
DateTimeValidatorInstance
validator
=
Validator
.
DateTimeValidatorInstance
@
property
def
_get_sub_form
(
self
,
field
=
None
):
def
sub_form
(
self
):
if
field
is
None
:
input_style
=
self
.
get_value
(
'input_style'
)
field
=
self
input_style
=
field
.
get_value
(
'input_style'
)
if
input_style
==
'text'
:
if
input_style
==
'text'
:
return
create_datetime_text_sub_form
(
self
)
return
create_datetime_text_sub_form
(
self
)
elif
input_style
==
'list'
:
elif
input_style
==
'list'
:
...
...
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