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

fix security declaration of getRootCausalityValueList and setDefaultDeliveryProperties. wrap lines

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6322 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ecc6f34a
...@@ -120,32 +120,37 @@ class SimulationMovement(Movement): ...@@ -120,32 +120,37 @@ class SimulationMovement(Movement):
return self.objectValues() return self.objectValues()
# Price should be acquired # Price should be acquired
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice') security.declareProtected( Permissions.AccessContentsInformation,
'getPrice')
def getPrice(self, context=None, REQUEST=None, **kw): def getPrice(self, context=None, REQUEST=None, **kw):
""" """
""" """
return self._baseGetPrice() # Call the price method return self._baseGetPrice() # Call the price method
security.declareProtected(Permissions.AccessContentsInformation, 'getCausalityState') security.declareProtected( Permissions.AccessContentsInformation,
'getCausalityState')
def getCausalityState(self): def getCausalityState(self):
""" """
Returns the current state in causality Returns the current state in causality
""" """
return getattr(self, 'causality_state', 'solved') return getattr(self, 'causality_state', 'solved')
security.declareProtected( Permissions.ModifyPortalContent,
'setCausalityState')
def setCausalityState(self, value): def setCausalityState(self, value):
""" """
Change causality state Change causality state
""" """
self.causality_state = value self.causality_state = value
security.declareProtected(Permissions.AccessContentsInformation, 'getSimulationState') security.declareProtected( Permissions.AccessContentsInformation,
'getSimulationState')
def getSimulationState(self, id_only=1): def getSimulationState(self, id_only=1):
""" """
Returns the current state in simulation Returns the current state in simulation
Inherit from order or delivery or parent (but use a conversion table to make Inherit from order or delivery or parent (but use a conversion
orders planned when parent is confirmed) table to make orders planned when parent is confirmed)
XXX: movements in zero stock rule can not acquire simulation state XXX: movements in zero stock rule can not acquire simulation state
""" """
...@@ -159,11 +164,12 @@ class SimulationMovement(Movement): ...@@ -159,11 +164,12 @@ class SimulationMovement(Movement):
parent_state = self.aq_parent.getSimulationState() parent_state = self.aq_parent.getSimulationState()
return parent_to_movement_simulation_state[parent_state] return parent_to_movement_simulation_state[parent_state]
except KeyError, AttributeError: except KeyError, AttributeError:
LOG('ERP5 WARNING:',100, 'Could not acquire getSimulationState on %s' % self.getRelativeUrl()) LOG('ERP5 WARNING:',100, 'Could not acquire getSimulationState on %s'
% self.getRelativeUrl())
return None return None
# Acounting security.declareProtected( Permissions.AccessContentsInformation,
security.declareProtected(Permissions.AccessContentsInformation, 'isAccountable') 'isAccountable')
def isAccountable(self): def isAccountable(self):
""" """
Returns 1 if this needs to be accounted Returns 1 if this needs to be accounted
...@@ -173,7 +179,8 @@ class SimulationMovement(Movement): ...@@ -173,7 +179,8 @@ class SimulationMovement(Movement):
return (self.getDeliveryValue() is None) return (self.getDeliveryValue() is None)
# Ordering / Delivering # Ordering / Delivering
security.declareProtected(Permissions.AccessContentsInformation, 'requiresOrder') security.declareProtected( Permissions.AccessContentsInformation,
'requiresOrder')
def requiresOrder(self): def requiresOrder(self):
""" """
Returns 1 if this needs to be ordered Returns 1 if this needs to be ordered
...@@ -183,7 +190,8 @@ class SimulationMovement(Movement): ...@@ -183,7 +190,8 @@ class SimulationMovement(Movement):
else: else:
return 0 return 0
security.declareProtected(Permissions.AccessContentsInformation, 'requiresDelivery') security.declareProtected( Permissions.AccessContentsInformation,
'requiresDelivery')
def requiresDelivery(self): def requiresDelivery(self):
""" """
Returns 1 if this needs to be accounted Returns 1 if this needs to be accounted
...@@ -246,7 +254,8 @@ class SimulationMovement(Movement): ...@@ -246,7 +254,8 @@ class SimulationMovement(Movement):
# isDivergent is defined in movement # isDivergent is defined in movement
# Optimized Reindexing # Optimized Reindexing
security.declareProtected(Permissions.AccessContentsInformation, 'getMovementIndex') security.declareProtected( Permissions.AccessContentsInformation,
'getMovementIndex')
def getMovementIndex(self): def getMovementIndex(self):
""" """
Returns a list of indexable movements Returns a list of indexable movements
...@@ -341,7 +350,8 @@ class SimulationMovement(Movement): ...@@ -341,7 +350,8 @@ class SimulationMovement(Movement):
return 0 return 0
# Deliverability / orderability # Deliverability / orderability
security.declareProtected(Permissions.AccessContentsInformation, 'isOrderable') security.declareProtected( Permissions.AccessContentsInformation,
'isOrderable')
def isOrderable(self): def isOrderable(self):
applied_rule = self.aq_parent applied_rule = self.aq_parent
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
...@@ -351,7 +361,8 @@ class SimulationMovement(Movement): ...@@ -351,7 +361,8 @@ class SimulationMovement(Movement):
getOrderable = isOrderable getOrderable = isOrderable
security.declareProtected(Permissions.AccessContentsInformation, 'isDeliverable') security.declareProtected( Permissions.AccessContentsInformation,
'isDeliverable')
def isDeliverable(self): def isDeliverable(self):
applied_rule = self.aq_parent applied_rule = self.aq_parent
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
...@@ -362,20 +373,22 @@ class SimulationMovement(Movement): ...@@ -362,20 +373,22 @@ class SimulationMovement(Movement):
getDeliverable = isDeliverable getDeliverable = isDeliverable
# Simulation Dates - acquire target dates # Simulation Dates - acquire target dates
security.declareProtected(Permissions.AccessContentsInformation, 'getOrderStartDate') security.declareProtected( Permissions.AccessContentsInformation,
'getOrderStartDate')
def getOrderStartDate(self): def getOrderStartDate(self):
order_value = self.getOrderValue() order_value = self.getOrderValue()
if order_value is not None: if order_value is not None:
return order_value.getStartDate() return order_value.getStartDate()
security.declareProtected(Permissions.AccessContentsInformation, 'getOrderStopDate') security.declareProtected( Permissions.AccessContentsInformation,
'getOrderStopDate')
def getOrderStopDate(self): def getOrderStopDate(self):
order_value = self.getOrderValue() order_value = self.getOrderValue()
if order_value is not None: if order_value is not None:
return order_value.getStopDate() return order_value.getStopDate()
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDeliveryStartDateList') 'getDeliveryStartDateList')
def getDeliveryStartDateList(self): def getDeliveryStartDateList(self):
""" """
Returns the stop date of related delivery(s) Returns the stop date of related delivery(s)
...@@ -386,8 +399,8 @@ class SimulationMovement(Movement): ...@@ -386,8 +399,8 @@ class SimulationMovement(Movement):
start_date_list.append(delivery_movement.getStartDate()) start_date_list.append(delivery_movement.getStartDate())
return start_date_list return start_date_list
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDeliveryStopDateList') 'getDeliveryStopDateList')
def getDeliveryStopDateList(self): def getDeliveryStopDateList(self):
""" """
Returns the stop date of related delivery(s) Returns the stop date of related delivery(s)
...@@ -398,8 +411,8 @@ class SimulationMovement(Movement): ...@@ -398,8 +411,8 @@ class SimulationMovement(Movement):
stop_date_list.append(delivery_movement.getStopDate()) stop_date_list.append(delivery_movement.getStopDate())
return stop_date_list return stop_date_list
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDeliveryQuantity') 'getDeliveryQuantity')
def getDeliveryQuantity(self): def getDeliveryQuantity(self):
""" """
Returns the quantity of related delivery(s) Returns the quantity of related delivery(s)
...@@ -410,15 +423,17 @@ class SimulationMovement(Movement): ...@@ -410,15 +423,17 @@ class SimulationMovement(Movement):
quantity = delivery_movement.getQuantity() quantity = delivery_movement.getQuantity()
return quantity return quantity
security.declareProtected(Permissions.AccessContentsInformation, 'isConvergent') security.declareProtected( Permissions.AccessContentsInformation,
'isConvergent')
def isConvergent(self): def isConvergent(self):
""" """
Returns true if the Simulation Movement is convergent comparing to the delivery value Returns true if the Simulation Movement is convergent comparing to
the delivery value
""" """
return not self.isDivergent() return not self.isDivergent()
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'isDivergent') 'isDivergent')
def isDivergent(self): def isDivergent(self):
""" """
Returns true if the Simulation Movement is divergent comparing to Returns true if the Simulation Movement is divergent comparing to
...@@ -468,23 +483,26 @@ class SimulationMovement(Movement): ...@@ -468,23 +483,26 @@ class SimulationMovement(Movement):
# if the delivery_ratio is None, make sure that we are # if the delivery_ratio is None, make sure that we are
# divergent even if the delivery quantity is 0 # divergent even if the delivery quantity is 0
if delivery_ratio is not None: if delivery_ratio is not None:
d_quantity *= delivery_ratio d_quantity *= delivery_ratio
if delivery_ratio == 0 and quantity >0: if delivery_ratio == 0 and quantity >0:
return 1 return 1
if d_quantity != quantity + d_error: if d_quantity != quantity + d_error:
return 1 return 1
return 0 return 0
security.declareProtected(Permissions.View, 'setDefaultDeliveryProperties') security.declareProtected( Permissions.ModifyPortalContent,
'setDefaultDeliveryProperties')
def setDefaultDeliveryProperties(self): def setDefaultDeliveryProperties(self):
""" """
Sets the delivery_ratio and delivery_error properties to the calculated value Sets the delivery_ratio and delivery_error properties to the
calculated value
""" """
delivery = self.getDeliveryValue() delivery = self.getDeliveryValue()
if delivery is not None: if delivery is not None:
delivery.updateSimulationDeliveryProperties(movement_list = [self]) delivery.updateSimulationDeliveryProperties(movement_list = [self])
security.declareProtected(Permissions.View, 'getCorrectedQuantity') security.declareProtected( Permissions.AccessContentsInformation,
'getCorrectedQuantity')
def getCorrectedQuantity(self): def getCorrectedQuantity(self):
""" """
Returns the quantity property deducted by the possible profit_quantity Returns the quantity property deducted by the possible profit_quantity
...@@ -497,10 +515,12 @@ class SimulationMovement(Movement): ...@@ -497,10 +515,12 @@ class SimulationMovement(Movement):
return quantity return quantity
return None return None
security.declareProtected(Permissions.View, 'getRootSimulationMovement') security.declareProtected( Permissions.AccessContentsInformation,
'getRootSimulationMovement')
def getRootSimulationMovement(self): def getRootSimulationMovement(self):
""" """
Return the root simulation movement in the simulation tree. Return the root simulation movement in the simulation tree.
FIXME : this method should be called getRootSimulationMovementValue
""" """
parent_applied_rule = self.getParent() parent_applied_rule = self.getParent()
if parent_applied_rule.getRootAppliedRule() == parent_applied_rule: if parent_applied_rule.getRootAppliedRule() == parent_applied_rule:
...@@ -508,7 +528,8 @@ class SimulationMovement(Movement): ...@@ -508,7 +528,8 @@ class SimulationMovement(Movement):
else: else:
return parent_applied_rule.getRootSimulationMovement() return parent_applied_rule.getRootSimulationMovement()
security.declareProtected(Permissions.View, 'getRootSimulationMovementUid') security.declareProtected( Permissions.AccessContentsInformation,
'getRootSimulationMovementUid')
def getRootSimulationMovementUid(self): def getRootSimulationMovementUid(self):
""" """
Return the uid of the root simulation movement in the simulation tree. Return the uid of the root simulation movement in the simulation tree.
...@@ -519,7 +540,7 @@ class SimulationMovement(Movement): ...@@ -519,7 +540,7 @@ class SimulationMovement(Movement):
return None return None
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getInitialCausalityValueList') 'getRootCausalityValueList')
def getRootCausalityValueList(self): def getRootCausalityValueList(self):
""" """
Returns the initial causality value for this movement. Returns the initial causality value for this movement.
......
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