Commit 101d0a44 authored by Romain Courteaud's avatar Romain Courteaud

Added VariationPropertyMovementGroup.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4108 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a54722da
......@@ -524,6 +524,45 @@ class OptionMovementGroup(RootMovementGroup):
allow_class(OptionMovementGroup)
class VariationPropertyMovementGroup(RootMovementGroup):
"""
Compare variation property dict of movement.
"""
def __init__(self, movement, **kw):
"""
Store variation property dict of the first movement.
"""
RootMovementGroup.__init__(self, movement=movement, **kw)
self.property_dict = movement.getVariationPropertyDict()
self.setGroupEdit(
variation_property_dict = self.property_dict
)
def test(self, movement):
"""
Check if the movement can be inserted in the group.
"""
identity = 0
variation_property_dict = movement.getVariationPropertyDict()
variation_property_list = variation_property_dict.keys()
if len(variation_property_list) == len(self.property_dict):
# Same number of property. Good point.
for variation_property in variation_property_list:
try:
if variation_property_dict[variation_property] != \
self.property_dict[variation_property]
# Value is not the same for both movements
break
except KeyError:
# Key is not common to both movements
break
else:
identity = 1
return identity
allow_class(VariationPropertyMovementGroup)
class FakeMovement:
"""
A fake movement which simulate some methods on a movement needed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment