Commit e2e4f433 authored by Jérome Perrin's avatar Jérome Perrin

isDivergent: fix docstring and return a boolean

parent d16118b7
...@@ -103,14 +103,10 @@ class Container(Movement, XMLObject): ...@@ -103,14 +103,10 @@ class Container(Movement, XMLObject):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent') security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self): def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Containers are never divergent.
""" """
Returns 1 if the target is not met according to the current information return False
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
return 0
def getContainerText(self): def getContainerText(self):
""" """
......
...@@ -72,12 +72,7 @@ class ContainerCell(DeliveryCell): ...@@ -72,12 +72,7 @@ class ContainerCell(DeliveryCell):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent') security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self): def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Container Cells are never divergent.
""" """
Returns 1 if the target is not met according to the current information return False
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
# Never divergent
return 0
...@@ -81,15 +81,10 @@ class ContainerLine(DeliveryLine): ...@@ -81,15 +81,10 @@ class ContainerLine(DeliveryLine):
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent') security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self): def isDivergent(self):
"""Return True if this movement diverges from the its simulation.
Container Lines are never divergent.
""" """
Returns 1 if the target is not met according to the current information return False
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
"""
# Never divergent
return 0
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getTotalQuantity')
def getTotalQuantity(self): def getTotalQuantity(self):
......
...@@ -334,7 +334,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin, ...@@ -334,7 +334,7 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
""" """
Returns 0 if the target is not met Returns 0 if the target is not met
""" """
return int(not self.isDivergent(**kw)) return bool(not self.isDivergent(**kw))
security.declareProtected(Permissions.AccessContentsInformation, 'isSimulated') security.declareProtected(Permissions.AccessContentsInformation, 'isSimulated')
def isSimulated(self): def isSimulated(self):
...@@ -349,20 +349,15 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin, ...@@ -349,20 +349,15 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent') security.declareProtected(Permissions.AccessContentsInformation, 'isDivergent')
def isDivergent(self, fast=0, **kw): def isDivergent(self, fast=0, **kw):
""" """Return True if this movement diverges from the its simulation.
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
""" """
## Note that fast option was removed. Now, fast=1 is ignored. ## Note that fast option was removed. Now, fast=1 is ignored.
# Check if the total quantity equals the total of each simulation movement quantity # Check if the total quantity equals the total of each simulation movement quantity
for simulation_movement in self._getAllRelatedSimulationMovementList(): for simulation_movement in self._getAllRelatedSimulationMovementList():
if simulation_movement.isDivergent(): if simulation_movement.isDivergent():
return 1 return True
return 0 return False
security.declareProtected(Permissions.AccessContentsInformation, 'getDivergenceList') security.declareProtected(Permissions.AccessContentsInformation, 'getDivergenceList')
def getDivergenceList(self, **kw): def getDivergenceList(self, **kw):
......
...@@ -488,13 +488,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -488,13 +488,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'isDivergent') 'isDivergent')
def isDivergent(self): def isDivergent(self):
""" """Return True if this movement diverges from the its simulation.
XXX documentation out of sync with actual use
Returns 1 if the target is not met according to the current information
After and edit, the isOutOfTarget will be checked. If it is 1,
a message is emitted
emit targetUnreachable !
""" """
for simulation_movement in self.getDeliveryRelatedValueList(): for simulation_movement in self.getDeliveryRelatedValueList():
if simulation_movement.isDivergent(): if simulation_movement.isDivergent():
......
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