Commit a021f476 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Rule should be IDivergenceController.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31196 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 45396ecc
......@@ -50,6 +50,7 @@ class RuleMixin:
# Declarative interfaces
zope.interface.implements(interfaces.IRule,
interfaces.IDivergenceController,
interfaces.IMovementCollectionUpdater,)
# Portal Type of created children
......@@ -101,6 +102,40 @@ class RuleMixin:
for movement in applied_rule.getMovementList():
movement.expand(**kw)
# Implementation of IDivergenceController
security.declareProtected( Permissions.AccessContentsInformation,
'isDivergent')
def isDivergent(self, movement, ignore_list=[]):
"""
Returns true if the Simulation Movement is divergent comparing to
the delivery value
"""
delivery = movement.getDeliveryValue()
if delivery is None:
return False
if len(self.getDivergenceList(movement)) == 0:
return False
else:
return True
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
result_list = []
for divergence_tester in self._getDivergenceTesterList():
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
# Implementation of IMovementCollectionUpdater
def getMovementCollectionDiff(self, context, rounding=False, movement_generator=None):
"""
......
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