fixed can_delete called from parent

This commit is contained in:
Thomas Desvenain 2014-09-05 11:11:54 +02:00
parent 2ba35bb0d4
commit a94b3249a9

View File

@ -132,18 +132,19 @@ class DeleteOwnComment(DeleteComment):
* Owner role directly assigned on the comment object * Owner role directly assigned on the comment object
""" """
def could_delete(self): def could_delete(self, comment=None):
"""returns true if the comment could be deleted if it had no replies.""" """returns true if the comment could be deleted if it had no replies."""
sm = getSecurityManager() sm = getSecurityManager()
context = aq_inner(self.context) comment = comment or aq_inner(self.context)
userid = sm.getUser().getId() userid = sm.getUser().getId()
return (sm.checkPermission('Delete own comments', return (sm.checkPermission('Delete own comments',
context) comment)
and 'Owner' in context.get_local_roles_for_userid(userid)) and 'Owner' in comment.get_local_roles_for_userid(userid))
def can_delete(self): def can_delete(self, comment=None):
return (len(IReplies(aq_inner(self.context))) == 0 comment = comment or self.context
and self.could_delete()) return (len(IReplies(aq_inner(comment))) == 0
and self.could_delete(comment=comment))
def __call__(self): def __call__(self):
if self.can_delete(): if self.can_delete():