From a94b3249a9f38f24fe76248810bcd22371aa0a02 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Fri, 5 Sep 2014 11:11:54 +0200 Subject: [PATCH] fixed can_delete called from parent --- plone/app/discussion/browser/moderation.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plone/app/discussion/browser/moderation.py b/plone/app/discussion/browser/moderation.py index 93f0b97..21aef4a 100644 --- a/plone/app/discussion/browser/moderation.py +++ b/plone/app/discussion/browser/moderation.py @@ -132,18 +132,19 @@ class DeleteOwnComment(DeleteComment): * 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.""" sm = getSecurityManager() - context = aq_inner(self.context) + comment = comment or aq_inner(self.context) userid = sm.getUser().getId() return (sm.checkPermission('Delete own comments', - context) - and 'Owner' in context.get_local_roles_for_userid(userid)) + comment) + and 'Owner' in comment.get_local_roles_for_userid(userid)) - def can_delete(self): - return (len(IReplies(aq_inner(self.context))) == 0 - and self.could_delete()) + def can_delete(self, comment=None): + comment = comment or self.context + return (len(IReplies(aq_inner(comment))) == 0 + and self.could_delete(comment=comment)) def __call__(self): if self.can_delete():