Commit d2dadc7a authored by Julien Muchembled's avatar Julien Muchembled

Review Base.isDeletable and SimulationMovement.isDeletable

parent 5a967a85
......@@ -354,7 +354,12 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
security.declareProtected( Permissions.AccessContentsInformation,
'isDeletable')
def isDeletable(self, **kw):
def isDeletable(self, check_relation=None):
if check_relation is not None:
if not super(SimulationMovement, self).isDeletable(False):
return False
if not check_relation:
return True
return not self.isFrozen() and not self._isTreeDelivered()
# Simulation Dates - acquire target dates
......
......@@ -2686,8 +2686,14 @@ class Base( CopyContainer,
security.declareProtected(Permissions.AccessContentsInformation,
'isDeletable')
def isDeletable(self, check_relation=True):
"""Test if object can be delete"""
def isDeletable(self, check_relation):
"""Test if object can be deleted
The lack of default value for `check_relation` is intentional. Because
checking relation can take a lot of time, it forces the caller to choose
between performance (e.g. to control the visibility of an action) and
correctness (e.g. just before deleting objects).
"""
container = self.getParentValue()
portal = container.getPortalObject()
return (portal.portal_workflow.isTransitionPossible(self, 'delete')
......
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