Commit 9c88f08e authored by Jérome Perrin's avatar Jérome Perrin

protect methods with AccessContentsInformation, not View

simplify some constructions
don't accept id_only=1 in getImmobilisationState, it's not part of workflow state getter API



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28087 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0090bbf8
......@@ -79,7 +79,8 @@ class ImmobilisableItem(XMLObject, Amount):
, PropertySheet.Amortisation
)
security.declareProtected(Permissions.View, 'getImmobilisationRelatedMovementList')
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationRelatedMovementList')
def getImmobilisationRelatedMovementList(self,
from_date = None,
to_date = None,
......@@ -213,7 +214,8 @@ class ImmobilisableItem(XMLObject, Amount):
return None
return organisation
security.declareProtected(Permissions.View, 'getImmobilisationMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationMovementValueList')
def getImmobilisationMovementValueList(self,
from_date=None,
to_date=None,
......@@ -230,7 +232,8 @@ class ImmobilisableItem(XMLObject, Amount):
immobilisation_and_owner_change=1,
**kw)
security.declareProtected(Permissions.View, 'getUnfilteredImmobilisationMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation,
'getUnfilteredImmobilisationMovementValueList')
def getUnfilteredImmobilisationMovementValueList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of immobilisation applied to the current item from date to date
......@@ -240,7 +243,8 @@ class ImmobilisableItem(XMLObject, Amount):
to_date=to_date,
filter_valid=0, **kw)
security.declareProtected(Permissions.View, 'getPastImmobilisationMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation,
'getPastImmobilisationMovementValueList')
def getPastImmobilisationMovementValueList(self, from_date=None, at_date=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
......@@ -251,7 +255,8 @@ class ImmobilisableItem(XMLObject, Amount):
to_date=at_date, **kw )
return result
security.declareProtected(Permissions.View, 'getFutureImmobilisationMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation,
'getFutureImmobilisationMovementValueList')
def getFutureImmobilisationMovementValueList(self, to_date=None, at_date=None, from_movement=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
......@@ -267,7 +272,8 @@ class ImmobilisableItem(XMLObject, Amount):
return result
security.declareProtected(Permissions.View, 'getLastImmobilisationMovementValue')
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationMovementValue')
def getLastImmobilisationMovementValue(self, at_date=None, **kw):
"""
Returns the last immobilisation movement before the given date, or now
......@@ -277,7 +283,8 @@ class ImmobilisableItem(XMLObject, Amount):
return past_list[-1]
return None
security.declareProtected(Permissions.View, 'getNextImmobilisationMovementValue')
security.declareProtected(Permissions.AccessContentsInformation,
'getNextImmobilisationMovementValue')
def getNextImmobilisationMovementValue(self, at_date=None, from_movement=None, **kw):
"""
Returns the first immobilisation movement after the given date, or now
......@@ -292,7 +299,8 @@ class ImmobilisableItem(XMLObject, Amount):
return future_list[0]
return None
security.declareProtected(Permissions.View, 'getImmobilisationPeriodList')
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationPeriodList')
def getImmobilisationPeriodList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of dictionaries representing immobilisation periods for the object
......@@ -587,7 +595,8 @@ class ImmobilisableItem(XMLObject, Amount):
tuple([(key,kw[key]) for key in kw_key_list]) ] = immo_period_list
return immo_period_list
security.declareProtected(Permissions.View, 'getLastImmobilisationPeriod')
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationPeriod')
def getLastImmobilisationPeriod(self, to_date=None, **kw):
"""
Returns the current immobilisation period, or the last one if the
......@@ -599,18 +608,21 @@ class ImmobilisableItem(XMLObject, Amount):
return None
return period_list[-1]
security.declareProtected(Permissions.View, 'isCurrentlyImmobilised')
security.declareProtected(Permissions.AccessContentsInformation,
'isCurrentlyImmobilised')
def isCurrentlyImmobilised(self, **kw):
""" Returns true if the item is immobilised at this time """
return self.isImmobilised(at_date = DateTime(), **kw)
security.declareProtected(Permissions.View, 'isNotCurrentlyImmobilised')
security.declareProtected(Permissions.AccessContentsInformation,
'isNotCurrentlyImmobilised')
def isNotCurrentlyImmobilised(self, **kw):
""" Returns true if the item is not immobilised at this time """
return not self.isCurrentlyImmobilised(**kw)
security.declareProtected(Permissions.View, 'isImmobilised')
security.declareProtected(Permissions.AccessContentsInformation,
'isImmobilised')
def isImmobilised(self, at_date=None, **kw):
"""
Returns true if the item is immobilised at the given date.
......@@ -627,14 +639,16 @@ class ImmobilisableItem(XMLObject, Amount):
return 0
return 1
security.declareProtected(Permissions.View, 'getCurrentRemainingAmortisationDuration')
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingAmortisationDuration')
def getCurrentRemainingAmortisationDuration(self, **kw):
""" Returns the calculated remaining amortisation duration for this item
at the current time.
"""
return self.getRemainingAmortisationDuration(at_date=DateTime(), **kw)
security.declareProtected(Permissions.View, 'getRemainingAmortisationDuration')
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingAmortisationDuration')
def getRemainingAmortisationDuration(self, at_date=None, **kw):
"""
Returns the calculated remaining amortisation duration for the item.
......@@ -663,7 +677,8 @@ class ImmobilisableItem(XMLObject, Amount):
return int(remaining_duration)
return None
security.declareProtected(Permissions.View, 'getRemainingDurability')
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingDurability')
def getRemainingDurability(self, at_date=None, **kw):
"""
Returns the durability of the item at the given date, or now.
......@@ -735,7 +750,8 @@ class ImmobilisableItem(XMLObject, Amount):
return start_durability - consumpted_durability * current_consumpted_time / consumpted_time
security.declareProtected(Permissions.View, 'getCurrentRemainingDurability')
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingDurability')
def getCurrentRemainingDurability(self, **kw):
"""
Returns the remaining durability at the current date
......@@ -743,7 +759,8 @@ class ImmobilisableItem(XMLObject, Amount):
return self.getRemainingDurability(at_date=DateTime(), **kw)
security.declareProtected(Permissions.View, 'getAmortisationPrice')
security.declareProtected(Permissions.AccessContentsInformation,
'getAmortisationPrice')
def getAmortisationPrice(self, at_date=None, with_currency=0, **kw):
"""
Returns the deprecated value of item at given date, or now.
......@@ -992,13 +1009,13 @@ class ImmobilisableItem(XMLObject, Amount):
return '%0.2f %s' % (returned_price, currency)
return returned_price
security.declareProtected(Permissions.View, 'getCurrentAmortisationPrice')
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentAmortisationPrice')
def getCurrentAmortisationPrice(self, with_currency=0, **kw):
""" Returns the deprecated value of item at current time """
return self.getAmortisationPrice(at_date=DateTime(),
with_currency=with_currency, **kw)
security.declareProtected(Permissions.ModifyPortalContent, '_createAmortisationRule')
def _createAmortisationRule(self):
"""
Build or update the amortisation rule related to this item, then expand the rule
......@@ -1033,7 +1050,8 @@ class ImmobilisableItem(XMLObject, Amount):
# It is time to expand it
my_applied_rule.expand()
security.declareProtected(Permissions.View, 'expandAmortisation')
security.declareProtected(Permissions.AccessContentsInformation,
'expandAmortisation')
def expandAmortisation(self,**kw):
"""
Calculate the amortisation annuities for the item
......@@ -1052,7 +1070,8 @@ class ImmobilisableItem(XMLObject, Amount):
after_tag='expand_amortisation'
).immediateExpandAmortisation()
security.declareProtected(Permissions.View, 'immediateExpandAmortisation')
security.declareProtected(Permissions.AccessContentsInformation,
'immediateExpandAmortisation')
def immediateExpandAmortisation(self):
"""
Calculate the amortisation annuities for the item
......@@ -1068,7 +1087,7 @@ class ImmobilisableItem(XMLObject, Amount):
delivery.updateImmobilisationState()
self.activate().expandAmortisation(activate_kw=activate_kw)
security.declareProtected(Permissions.View, 'getSectionMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionMovementValueList')
def getSectionMovementValueList(self, include_to_date=0, **kw):
"""
Return the list of successive movements affecting
......@@ -1102,7 +1121,7 @@ class ImmobilisableItem(XMLObject, Amount):
movement_list.append(movement)
return movement_list
security.declareProtected(Permissions.View, 'getSectionChangeList')
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionChangeList')
def getSectionChangeList(self, at_date=None, **kw):
"""
Return the list of successive owners of the item with
......@@ -1134,7 +1153,7 @@ class ImmobilisableItem(XMLObject, Amount):
'movement' : movement } )
return owner_list
security.declareProtected(Permissions.View, 'getSectionValue')
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionValue')
def getSectionValue(self, at_date=None, **kw):
"""
Return the owner of the item at the given date
......@@ -1145,7 +1164,7 @@ class ImmobilisableItem(XMLObject, Amount):
return owner_list[-1]['owner']
return None
security.declareProtected(Permissions.View, 'getCurrentSectionValue')
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentSectionValue')
def getCurrentSectionValue(self, **kw):
"""
Return the current owner of the item
......
......@@ -77,7 +77,7 @@ class ImmobilisationDelivery(XMLObject):
, PropertySheet.Reference
)
security.declareProtected(Permissions.View, 'updateImmobilisationState')
security.declareProtected(Permissions.AccessContentsInformation, 'updateImmobilisationState')
def updateImmobilisationState(self, **kw):
"""
This is often called as an activity, it will check if the
......@@ -94,7 +94,7 @@ class ImmobilisationDelivery(XMLObject):
except ImmobilisationValidityError:
self.calculateImmobilisationValidity()
security.declareProtected(Permissions.View, 'getImmobilisationMovementList')
security.declareProtected(Permissions.AccessContentsInformation, 'getImmobilisationMovementList')
def getImmobilisationMovementList(self, **kw):
"""
Return regular movements + immobilisation movements like
......@@ -103,7 +103,7 @@ class ImmobilisationDelivery(XMLObject):
return self.getMovementList(self.getPortalMovementTypeList() +
('Immobilisation Line', 'Immobilisation Cell'), **kw)
security.declareProtected(Permissions.View, 'checkImmobilisationConsistency')
security.declareProtected(Permissions.AccessContentsInformation, 'checkImmobilisationConsistency')
def checkImmobilisationConsistency(self, *args, **kw):
"""
Check the consistency about immobilisation values
......@@ -113,24 +113,23 @@ class ImmobilisationDelivery(XMLObject):
return_list.extend(movement.checkImmobilisationConsistency())
return return_list
security.declareProtected(Permissions.View, 'isValidImmobilisationMovement')
security.declareProtected(Permissions.AccessContentsInformation, 'isValidImmobilisationMovement')
def isValidImmobilisationMovement(self, *args, **kw):
"""
Return true if all submovements are valid in terms of immobilisation
"""
error_list = self.checkImmobilisationConsistency(*args, **kw)
if len(error_list) == 0:
return 1
return 0
return len(error_list) == 0
security.declareProtected(Permissions.View, 'isInvalidImmobilisationMovement')
security.declareProtected(Permissions.AccessContentsInformation, 'isInvalidImmobilisationMovement')
def isInvalidImmobilisationMovement(self, *args, **kw):
"""
Return false if all submovements are valid in terms of immobilisation
"""
return not self.isValidImmobilisationMovement(*args, **kw)
security.declareProtected(Permissions.View, 'getAggregatedItemsNextImmobilisationMovementValueList')
security.declareProtected(Permissions.AccessContentsInformation,
'getAggregatedItemsNextImmobilisationMovementValueList')
def getAggregatedItemsNextImmobilisationMovementValueList(self, **kw):
"""
Return the list of each next immobilisation movement for each aggregated item
......
......@@ -229,16 +229,17 @@ class ImmobilisationMovement(Movement, XMLObject):
return errors
security.declareProtected(Permissions.View, 'checkImmobilisationConsistency')
security.declareProtected(Permissions.AccessContentsInformation,
'checkImmobilisationConsistency')
def checkImmobilisationConsistency(self, *args, **kw):
"""
Checks the consistency about immobilisation values
"""
return_value = self._checkImmobilisationConsistency(*args, **kw)
return return_value
return self._checkImmobilisationConsistency(*args, **kw)
security.declareProtected(Permissions.View, 'getAmortisationMethodParameter')
security.declareProtected(Permissions.AccessContentsInformation,
'getAmortisationMethodParameter')
def getAmortisationMethodParameter(self, parameter_list, **kw):
"""
Returns a dictionary containing the value of each parameter
......@@ -251,7 +252,8 @@ class ImmobilisationMovement(Movement, XMLObject):
return self.getAmortisationMethodParameterForItem(None, parameter_list, **kw)
security.declareProtected(Permissions.View, 'getAmortisationMethodParameterForItem')
security.declareProtected(Permissions.AccessContentsInformation,
'getAmortisationMethodParameterForItem')
def getAmortisationMethodParameterForItem(self, item, parameter_list, split_char=None, split_qty=3, **kw):
"""
Returns a dictionary containing the value of each parameter
......@@ -299,7 +301,8 @@ class ImmobilisationMovement(Movement, XMLObject):
return parameter_dict
security.declareProtected(Permissions.View, 'getActualAmortisationMethodForItem')
security.declareProtected(Permissions.AccessContentsInformation,
'getActualAmortisationMethodForItem')
def getActualAmortisationMethodForItem(self, item, **kw):
"""
Returns the actual amortisation method by getting the previous
......@@ -322,7 +325,8 @@ class ImmobilisationMovement(Movement, XMLObject):
return None
security.declareProtected(Permissions.View, 'getNeededSpecificParameterListForItem')
security.declareProtected(Permissions.AccessContentsInformation,
'getNeededSpecificParameterListForItem')
def getNeededSpecificParameterListForItem(self, item, **kw):
"""
Returns the list of specific parameters which are
......@@ -335,7 +339,8 @@ class ImmobilisationMovement(Movement, XMLObject):
**kw)["needed_specific_parameter_list"]
security.declareProtected(Permissions.View, 'getUncontinuousNeededSpecificParameterListForItem')
security.declareProtected(Permissions.AccessContentsInformation,
'getUncontinuousNeededSpecificParameterListForItem')
def getUncontinuousNeededSpecificParameterListForItem(self, item, **kw):
"""
Returns the list of specific parameters which are
......@@ -349,7 +354,8 @@ class ImmobilisationMovement(Movement, XMLObject):
**kw)["uncontinuous_needed_specific_parameter_list"]
security.declareProtected(Permissions.View, 'getFacultativeSpecificParameterListForItem')
security.declareProtected(Permissions.AccessContentsInformation,
'getFacultativeSpecificParameterListForItem')
def getFacultativeSpecificParameterListForItem(self, item, **kw):
"""
Returns the list of specific parameters which are
......@@ -362,18 +368,19 @@ class ImmobilisationMovement(Movement, XMLObject):
**kw)["facultative_specific_parameter_list"]
security.declareProtected(Permissions.View, 'isUsingAmortisationMethod')
security.declareProtected(Permissions.AccessContentsInformation,
'isUsingAmortisationMethod')
def isUsingAmortisationMethod(self, method):
"""
Return true if this item is using the given method
"""
if self.getAmortisationMethod() == method:
return 1
return 0
return self.getAmortisationMethod() == method
security.declareProtected(Permissions.View, 'getImmobilisationState')
def getImmobilisationState(self, id_only=1):
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationState')
def getImmobilisationState(self):
"""
Return root delivery immobilisation state
"""
return self.getRootDeliveryValue().getImmobilisationState()
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