2016-02-05 01:39:53 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-04-16 17:54:19 +02:00
|
|
|
""" Custom discussion events
|
|
|
|
"""
|
|
|
|
from plone.app.discussion.interfaces import ICommentAddedEvent
|
|
|
|
from plone.app.discussion.interfaces import ICommentRemovedEvent
|
2015-05-03 08:16:39 +02:00
|
|
|
from plone.app.discussion.interfaces import IDiscussionEvent
|
2014-04-16 17:54:19 +02:00
|
|
|
from plone.app.discussion.interfaces import IReplyAddedEvent
|
|
|
|
from plone.app.discussion.interfaces import IReplyRemovedEvent
|
2015-05-03 08:16:39 +02:00
|
|
|
from zope.interface import implements
|
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
|
|
|
|
class DiscussionEvent(object):
|
|
|
|
""" Custom event
|
|
|
|
"""
|
|
|
|
implements(IDiscussionEvent)
|
|
|
|
|
2014-04-17 13:57:41 +02:00
|
|
|
def __init__(self, context, comment, **kwargs):
|
2014-04-16 17:54:19 +02:00
|
|
|
self.object = context
|
2014-04-17 13:57:41 +02:00
|
|
|
self.comment = comment
|
2014-04-16 17:54:19 +02:00
|
|
|
for key, value in kwargs.items():
|
|
|
|
setattr(self, key, value)
|
|
|
|
|
2014-09-20 14:14:19 +02:00
|
|
|
# Add event to the request to be able to access comment attributes
|
|
|
|
# in content-rules dynamic strings
|
|
|
|
request = context.REQUEST
|
|
|
|
request.set('event', self)
|
2014-04-17 17:38:44 +02:00
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
class CommentAddedEvent(DiscussionEvent):
|
|
|
|
""" Event to be triggered when a Comment is added
|
|
|
|
"""
|
|
|
|
implements(ICommentAddedEvent)
|
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
class CommentRemovedEvent(DiscussionEvent):
|
|
|
|
""" Event to be triggered when a Comment is removed
|
|
|
|
"""
|
|
|
|
implements(ICommentRemovedEvent)
|
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
class ReplyAddedEvent(DiscussionEvent):
|
|
|
|
""" Event to be triggered when a Comment reply is added
|
|
|
|
"""
|
|
|
|
implements(IReplyAddedEvent)
|
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
class ReplyRemovedEvent(DiscussionEvent):
|
|
|
|
""" Event to be triggered when a Comment reply is removed
|
|
|
|
"""
|
|
|
|
implements(IReplyRemovedEvent)
|