Move some policy out of the conversation storage adapter into a view,
specifically "enabled()". Prevents having to replace/migrate persistent objects to change policy which really only concerns the context and possibly the request, not the conversation storage. Fixes #11372. svn path=/plone.app.discussion/trunk/; revision=48849
This commit is contained in:
@@ -168,14 +168,15 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
if 'user_notification' in data:
|
||||
user_notification = data['user_notification']
|
||||
|
||||
# The add-comment view is called on the conversation object
|
||||
conversation = IConversation(self.__parent__)
|
||||
|
||||
# Check if conversation is enabled on this content object
|
||||
if not conversation.enabled():
|
||||
if not self.__parent__.restrictedTraverse(
|
||||
'@@conversation_view').enabled():
|
||||
raise Unauthorized, "Discussion is not enabled for this content\
|
||||
object."
|
||||
|
||||
# The add-comment view is called on the conversation object
|
||||
conversation = IConversation(self.__parent__)
|
||||
|
||||
if data['in_reply_to']:
|
||||
# Fetch the comment we want to reply to
|
||||
conversation_to_reply_to = conversation.get(data['in_reply_to'])
|
||||
@@ -291,8 +292,7 @@ class CommentsViewlet(ViewletBase):
|
||||
|
||||
def is_discussion_allowed(self):
|
||||
context = aq_inner(self.context)
|
||||
conversation = IConversation(context)
|
||||
return conversation.enabled()
|
||||
return context.restrictedTraverse('@@conversation_view').enabled()
|
||||
|
||||
def comment_transform_message(self):
|
||||
"""Returns the description that shows up above the comment text,
|
||||
|
||||
Reference in New Issue
Block a user