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
77037609
Commit
77037609
authored
Jan 11, 2021
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: unify Predicate_edit code into Base_edit.
parent
2419299d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
92 deletions
+39
-92
bt5/erp5_archive/SkinTemplateItem/portal_skins/erp5_archive/Archive_view.xml
...inTemplateItem/portal_skins/erp5_archive/Archive_view.xml
+1
-1
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testPredicate.py
...TemplateItem/portal_components/test.erp5.testPredicate.py
+6
-5
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py
...emplateItem/portal_skins/erp5_hal_json_style/Base_edit.py
+9
-0
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterion.zpt
...ortal_tests/erp5_web_zuite/testAddMembershipCriterion.zpt
+1
-1
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterionCategory.zpt
...sts/erp5_web_zuite/testAddMembershipCriterionCategory.zpt
+2
-2
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterionFallbackCategory.zpt
..._web_zuite/testAddMembershipCriterionFallbackCategory.zpt
+2
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
...core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
+8
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ContributionPredicate_view.xml
...tem/portal_skins/erp5_core/ContributionPredicate_view.xml
+1
-1
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_edit.py
...SkinTemplateItem/portal_skins/erp5_core/Predicate_edit.py
+8
-79
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_view.xml
...kinTemplateItem/portal_skins/erp5_core/Predicate_view.xml
+1
-1
No files found.
bt5/erp5_archive/SkinTemplateItem/portal_skins/erp5_archive/Archive_view.xml
View file @
77037609
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
Predicat
e_edit
</string>
</value>
<value>
<string>
Bas
e_edit
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
encoding
</string>
</key>
<key>
<string>
encoding
</string>
</key>
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testPredicate.py
View file @
77037609
...
@@ -35,7 +35,7 @@ import unittest
...
@@ -35,7 +35,7 @@ import unittest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
getSecurityManager
,
newSecurityManager
from
Products.ERP5Type.tests.Sequence
import
Sequence
from
Products.ERP5Type.tests.Sequence
import
Sequence
REGION_FRANCE_PATH
=
'region/europe/western_europe/france'
REGION_FRANCE_PATH
=
'region/europe/western_europe/france'
...
@@ -555,11 +555,12 @@ class TestPredicates(TestPredicateMixIn):
...
@@ -555,11 +555,12 @@ class TestPredicates(TestPredicateMixIn):
predicate
=
self
.
createPredicate
()
predicate
=
self
.
createPredicate
()
predicate
.
setCriterionPropertyList
([
'quantity'
])
predicate
.
setCriterionPropertyList
([
'quantity'
])
request
=
self
.
portal
.
REQUEST
request
=
self
.
portal
.
REQUEST
request
.
AUTHENTICATED_USER
=
getSecurityManager
().
getUser
()
request
.
set
(
request
.
set
(
'listbox'
,
'listbox'
,
{
'quantity'
:
{
'max'
:
''
,
'identity'
:
[],
'min'
:
''
}},
{
'quantity'
:
{
'max'
:
''
,
'identity'
:
[],
'min'
:
''
}},
)
)
predicate
.
Predicat
e_edit
(
'Predicate_view'
)
predicate
.
Bas
e_edit
(
'Predicate_view'
)
self
.
assertEqual
(
predicate
.
_identity_criterion
,
{
'quantity'
:
[]})
self
.
assertEqual
(
predicate
.
_identity_criterion
,
{
'quantity'
:
[]})
self
.
assertEqual
(
predicate
.
_range_criterion
,
{})
self
.
assertEqual
(
predicate
.
_range_criterion
,
{})
self
.
assertTrue
(
predicate
.
test
(
movement
))
self
.
assertTrue
(
predicate
.
test
(
movement
))
...
@@ -567,7 +568,7 @@ class TestPredicates(TestPredicateMixIn):
...
@@ -567,7 +568,7 @@ class TestPredicates(TestPredicateMixIn):
'listbox'
,
'listbox'
,
{
'quantity'
:
{
'max'
:
''
,
'identity'
:
[],
'min'
:
1.0
}},
{
'quantity'
:
{
'max'
:
''
,
'identity'
:
[],
'min'
:
1.0
}},
)
)
predicate
.
Predicat
e_edit
(
'Predicate_view'
)
predicate
.
Bas
e_edit
(
'Predicate_view'
)
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
1.0
,
None
)})
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
1.0
,
None
)})
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
0.5
)))
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
0.5
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.0
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.0
)))
...
@@ -575,7 +576,7 @@ class TestPredicates(TestPredicateMixIn):
...
@@ -575,7 +576,7 @@ class TestPredicates(TestPredicateMixIn):
'listbox'
,
'listbox'
,
{
'quantity'
:
{
'max'
:
2.0
,
'identity'
:
[],
'min'
:
''
}},
{
'quantity'
:
{
'max'
:
2.0
,
'identity'
:
[],
'min'
:
''
}},
)
)
predicate
.
Predicat
e_edit
(
'Predicate_view'
)
predicate
.
Bas
e_edit
(
'Predicate_view'
)
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
None
,
2.0
)})
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
None
,
2.0
)})
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
2.0
)))
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
2.0
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.5
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.5
)))
...
@@ -583,7 +584,7 @@ class TestPredicates(TestPredicateMixIn):
...
@@ -583,7 +584,7 @@ class TestPredicates(TestPredicateMixIn):
'listbox'
,
'listbox'
,
{
'quantity'
:
{
'max'
:
2.0
,
'identity'
:
[],
'min'
:
1.0
}},
{
'quantity'
:
{
'max'
:
2.0
,
'identity'
:
[],
'min'
:
1.0
}},
)
)
predicate
.
Predicat
e_edit
(
'Predicate_view'
)
predicate
.
Bas
e_edit
(
'Predicate_view'
)
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
1.0
,
2.0
)})
self
.
assertEqual
(
predicate
.
_range_criterion
,
{
'quantity'
:
(
1.0
,
2.0
)})
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
0.5
)))
self
.
assertFalse
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
0.5
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.0
)))
self
.
assertTrue
(
predicate
.
test
(
movement
.
asContext
(
quantity
=
1.0
)))
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_edit.py
View file @
77037609
...
@@ -62,6 +62,11 @@ def editListBox(listbox_field, listbox):
...
@@ -62,6 +62,11 @@ def editListBox(listbox_field, listbox):
if
listbox
is
None
:
if
listbox
is
None
:
return
return
if
context
.
isPredicate
():
predicate_listbox
=
set
(
context
.
getCriterionPropertyList
())
==
set
(
listbox
.
keys
())
else
:
predicate_listbox
=
False
# extract hidden (global) attributes from request to be used in listbox's update
# extract hidden (global) attributes from request to be used in listbox's update
# extract hidden (global) attributes from request to be used in listbox's update
global_attr
=
{
hidden_key
:
getattr
(
request
,
hidden_key
,
None
)
global_attr
=
{
hidden_key
:
getattr
(
request
,
hidden_key
,
None
)
for
hidden_key
,
_
in
listbox_field
.
get_value
(
'global_attributes'
)}
\
for
hidden_key
,
_
in
listbox_field
.
get_value
(
'global_attributes'
)}
\
...
@@ -69,6 +74,10 @@ def editListBox(listbox_field, listbox):
...
@@ -69,6 +74,10 @@ def editListBox(listbox_field, listbox):
else
{}
else
{}
for
item_url
,
item_value
in
listbox
.
items
():
for
item_url
,
item_value
in
listbox
.
items
():
if
predicate_listbox
:
item_value
.
update
(
global_attr
)
context
.
setCriterion
(
item_url
,
**
item_value
)
continue
item_value
.
update
(
global_attr
)
item_value
.
update
(
global_attr
)
# Form: '' -> ERP5: None
# Form: '' -> ERP5: None
editor_list
=
[]
editor_list
=
[]
...
...
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterion.zpt
View file @
77037609
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
clickAndWait
</td>
<td>
clickAndWait
</td>
<td>
//button[@name='
Predicat
e_edit:method']
</td>
<td>
//button[@name='
Bas
e_edit:method']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
...
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterionCategory.zpt
View file @
77037609
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
clickAndWait
</td>
<td>
clickAndWait
</td>
<td>
//button[@name='
Predicat
e_edit:method']
</td>
<td>
//button[@name='
Bas
e_edit:method']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
clickAndWait
</td>
<td>
clickAndWait
</td>
<td>
//button[@name='
Predicat
e_edit:method']
</td>
<td>
//button[@name='
Bas
e_edit:method']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
...
bt5/erp5_web_ui_test/PathTemplateItem/portal_tests/erp5_web_zuite/testAddMembershipCriterionFallbackCategory.zpt
View file @
77037609
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
clickAndWait
</td>
<td>
clickAndWait
</td>
<td>
//button[@name='
Predicat
e_edit:method']
</td>
<td>
//button[@name='
Bas
e_edit:method']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
</tr>
</tr>
<tr>
<tr>
<td>
clickAndWait
</td>
<td>
clickAndWait
</td>
<td>
//button[@name='
Predicat
e_edit:method']
</td>
<td>
//button[@name='
Bas
e_edit:method']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.py
View file @
77037609
...
@@ -56,11 +56,19 @@ def editListBox(listbox_field, listbox):
...
@@ -56,11 +56,19 @@ def editListBox(listbox_field, listbox):
"""
"""
if
listbox
is
not
None
:
if
listbox
is
not
None
:
global_property_dict
=
{}
global_property_dict
=
{}
if
context
.
isPredicate
():
predicate_listbox
=
set
(
context
.
getCriterionPropertyList
())
==
set
(
listbox
.
keys
())
else
:
predicate_listbox
=
False
if
listbox_field
.
has_value
(
'global_attributes'
):
if
listbox_field
.
has_value
(
'global_attributes'
):
hidden_attribute_list
=
[
x
[
0
]
for
x
in
listbox_field
.
get_value
(
'global_attributes'
)]
hidden_attribute_list
=
[
x
[
0
]
for
x
in
listbox_field
.
get_value
(
'global_attributes'
)]
for
hidden_attribute
in
hidden_attribute_list
:
for
hidden_attribute
in
hidden_attribute_list
:
global_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
global_property_dict
[
hidden_attribute
]
=
getattr
(
request
,
hidden_attribute
,
None
)
for
item_url
,
listbox_item_dict
in
listbox
.
items
():
for
item_url
,
listbox_item_dict
in
listbox
.
items
():
if
predicate_listbox
:
listbox_item_dict
.
update
(
global_property_dict
)
context
.
setCriterion
(
item_url
,
**
listbox_item_dict
)
continue
listbox_item_dict
.
update
(
global_property_dict
)
listbox_item_dict
.
update
(
global_property_dict
)
# Form: '' -> ERP5: None
# Form: '' -> ERP5: None
encapsulated_editor_list
=
[]
encapsulated_editor_list
=
[]
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ContributionPredicate_view.xml
View file @
77037609
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
Predicat
e_edit
</string>
</value>
<value>
<string>
Bas
e_edit
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
description
</string>
</key>
<key>
<string>
description
</string>
</key>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_edit.py
View file @
77037609
# Updates attributes of an Zope document
# BBB: now we can use Base_edit for Predicate_view.
# which is in a class inheriting from ERP5 Base
return
context
.
Base_edit
(
#
form_id
=
form_id
,
# TODO
selection_index
=
selection_index
,
# - Implement validation of matrix fields
selection_name
=
selection_name
,
# - Implement validation of list fields
ignore_layout
=
ignore_layout
,
#
editable_mode
=
editable_mode
,
from
Products.Formulator.Errors
import
FormValidationError
)
from
ZTUtils
import
make_query
request
=
context
.
REQUEST
try
:
# Define form basic fields
form
=
getattr
(
context
,
form_id
)
edit_order
=
form
.
edit_order
# Validate
form
.
validate_all_to_request
(
request
)
# Basic attributes
kw
=
{}
# Parse attributes
for
f
in
form
.
get_fields
():
k
=
f
.
id
v
=
getattr
(
request
,
k
,
None
)
if
v
is
not
None
:
if
k
[
0
:
3
]
==
'my_'
:
# We only take into account
# the object attributes
k
=
k
[
3
:]
kw
[
k
]
=
v
# Update listbox attributes
listbox
=
request
.
get
(
'listbox'
)
if
listbox
is
not
None
:
listbox_field
=
form
.
get_field
(
'listbox'
)
gv
=
{}
if
listbox_field
.
has_value
(
'global_attributes'
):
hidden_attributes
=
[
x
[
0
]
for
x
in
listbox_field
.
get_value
(
'global_attributes'
)]
for
k
in
hidden_attributes
:
gv
[
k
]
=
getattr
(
request
,
k
,
None
)
for
property_
,
v
in
listbox
.
items
():
v
.
update
(
gv
)
context
.
setCriterion
(
property_
,
**
v
)
# Update basic attributes
context
.
edit
(
REQUEST
=
request
,
edit_order
=
edit_order
,
**
kw
)
context
.
reindexObject
()
except
FormValidationError
,
validation_errors
:
# Pack errors into the request
field_errors
=
form
.
ErrorFields
(
validation_errors
)
request
.
set
(
'field_errors'
,
field_errors
)
return
form
(
request
)
else
:
# for web mode, we should use 'view' instead of passed form_id
# after 'Save & View'.
if
context
.
REQUEST
.
get
(
'is_web_mode'
,
False
)
and
\
not
editable_mode
:
form_id
=
'view'
if
not
selection_index
:
redirect_url
=
'%s/%s?%s'
%
(
context
.
absolute_url
(),
form_id
,
make_query
({
'ignore_layout'
:
ignore_layout
,
'editable_mode'
:
editable_mode
,
'portal_status_message'
:
'Data Updated.'
,
})
)
else
:
redirect_url
=
'%s/%s?%s'
%
(
context
.
absolute_url
(),
form_id
,
make_query
({
'selection_index'
:
selection_index
,
'selection_name'
:
selection_name
,
'ignore_layout'
:
ignore_layout
,
'editable_mode'
:
editable_mode
,
'portal_status_message'
:
'Data Updated.'
,
})
)
request
[
'RESPONSE'
].
redirect
(
redirect_url
)
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_view.xml
View file @
77037609
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
Predicat
e_edit
</string>
</value>
<value>
<string>
Bas
e_edit
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
description
</string>
</key>
<key>
<string>
description
</string>
</key>
...
...
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