Commit b947f4f3 authored by Xiaowu Zhang's avatar Xiaowu Zhang

Base: add isDeletable method to check if an object can be deleted

parent 1c10b4ef
......@@ -368,6 +368,11 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
return self
security.declareProtected(Permissions.AccessContentsInformation,
'isDeletable')
def isDeletable(self, check_relation):
return False
security.declarePrivate('manage_beforeDelete')
def manage_beforeDelete(self, item, container):
# skin is setup during __before_publishing_traverse__, which
......
......@@ -95,3 +95,8 @@ class Preference( Folder ):
def disable(self, **kw):
"""Workflow method"""
self._clearCache()
security.declareProtected(Permissions.AccessContentsInformation,
'isDeletable')
def isDeletable(self, check_relation):
return not (check_relation and self.getRelationCountForDeletion())
......@@ -2684,6 +2684,20 @@ class Base( CopyContainer,
else:
return False
security.declareProtected(Permissions.AccessContentsInformation,
'isDeletable')
def isDeletable(self, check_relation):
"""Test if object can be delete"""
portal = self.getPortalObject()
if not portal.portal_workflow.isTransitionPossible(self, 'delete'):
if not portal.portal_membership.checkPermission(
'Delete objects', self.getParentValue()):
return False
for wf_id in getattr(aq_base(self), "workflow_history", ()):
if wf_id != 'edit_workflow':
return False
return not (check_relation and self.getRelationCountForDeletion())
security.declareProtected(Permissions.AccessContentsInformation,
'isDeleted')
def isDeleted(self):
......
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