Use commented object as context instead of comment within event trigger

- In order this to work with plone.contentrules use commented object as
  the main context within custom discussion events and add comment as the
  second parameter.
This commit is contained in:
Alin Voinea
2014-04-18 16:33:12 +03:00
parent 4343197209
commit 14d4382ca6
4 changed files with 12 additions and 292 deletions
+8 -4
View File
@@ -250,16 +250,20 @@ def notify_content_object_deleted(obj, event):
def notify_comment_added(obj, event):
""" Notify custom discussion events when a comment is added or replied
"""
conversation = aq_parent(obj)
context = aq_parent(conversation)
if getattr(obj, 'in_reply_to', None):
return notify(ReplyAddedEvent(obj))
return notify(CommentAddedEvent(obj))
return notify(ReplyAddedEvent(context, obj))
return notify(CommentAddedEvent(context, obj))
def notify_comment_removed(obj, event):
""" Notify custom discussion events when a comment or reply is removed
"""
conversation = aq_parent(obj)
context = aq_parent(conversation)
if getattr(obj, 'in_reply_to', None):
return notify(ReplyRemovedEvent(obj))
return notify(CommentRemovedEvent(obj))
return notify(ReplyRemovedEvent(context, obj))
return notify(CommentRemovedEvent(context, obj))
def notify_content_object_moved(obj, event):
"""Update all comments of a content object that has been moved.