provide "delete own comments" as a configurable option
This commit is contained in:
committed by
Andrea Cecchi
parent
a82352a36c
commit
520b1e83f4
@@ -318,12 +318,28 @@ class CommentsViewlet(ViewletBase):
|
||||
aq_inner(self.context))
|
||||
|
||||
def can_edit(self, reply):
|
||||
"""Returns true if current user has the 'Delete objects'
|
||||
"""Returns true if current user has the 'Edit comments'
|
||||
permission.
|
||||
"""
|
||||
return getSecurityManager().checkPermission('Edit comments',
|
||||
aq_inner(reply))
|
||||
|
||||
def can_delete(self, reply):
|
||||
"""By default requires 'Review comments'.
|
||||
If 'delete own comments' is enabled, requires 'Edit comments'.
|
||||
"""
|
||||
if self.is_delete_own_comment_allowed():
|
||||
permission = 'Edit comments'
|
||||
else:
|
||||
permission = 'Review comments'
|
||||
return getSecurityManager().checkPermission(permission,
|
||||
aq_inner(reply))
|
||||
|
||||
def is_delete_own_comment_allowed(self):
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||
return settings.delete_own_comment_enabled
|
||||
|
||||
def is_discussion_allowed(self):
|
||||
context = aq_inner(self.context)
|
||||
return context.restrictedTraverse('@@conversation_view').enabled()
|
||||
|
||||
Reference in New Issue
Block a user