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
|
2018-10-24 16:49:22 +02:00
|
|
|
from plone.app.discussion.interfaces import ICommentDeletedEvent
|
2022-05-01 23:14:00 +02:00
|
|
|
from plone.app.discussion.interfaces import ICommentModifiedEvent
|
2018-10-24 16:49:22 +02:00
|
|
|
from plone.app.discussion.interfaces import ICommentPublishedEvent
|
2022-05-01 23:14:00 +02:00
|
|
|
from plone.app.discussion.interfaces import ICommentRemovedEvent
|
2019-12-08 20:01:40 +01:00
|
|
|
from plone.app.discussion.interfaces import ICommentTransitionEvent
|
2022-05-01 23:14:00 +02:00
|
|
|
from plone.app.discussion.interfaces import IDiscussionEvent
|
2014-04-16 17:54:19 +02:00
|
|
|
from plone.app.discussion.interfaces import IReplyAddedEvent
|
2021-09-08 13:02:34 +02:00
|
|
|
from plone.app.discussion.interfaces import IReplyModifiedEvent
|
2014-04-16 17:54:19 +02:00
|
|
|
from plone.app.discussion.interfaces import IReplyRemovedEvent
|
2016-07-05 23:12:08 +02:00
|
|
|
from zope.interface import implementer
|
2015-05-03 08:16:39 +02:00
|
|
|
|
2014-04-16 17:54:19 +02:00
|
|
|
|
2016-07-05 23:12:08 +02:00
|
|
|
@implementer(IDiscussionEvent)
|
2014-04-16 17:54:19 +02:00
|
|
|
class DiscussionEvent(object):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Custom event"""
|
2014-04-16 17:54:19 +02:00
|
|
|
|
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
|
2022-05-01 23:14:09 +02:00
|
|
|
request.set("event", self)
|
2014-04-17 17:38:44 +02:00
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2016-07-05 23:12:08 +02:00
|
|
|
@implementer(ICommentAddedEvent)
|
2014-04-16 17:54:19 +02:00
|
|
|
class CommentAddedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment is added"""
|
2014-04-16 17:54:19 +02:00
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2021-09-08 13:02:34 +02:00
|
|
|
@implementer(ICommentModifiedEvent)
|
|
|
|
class CommentModifiedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment is modified"""
|
2021-09-08 13:02:34 +02:00
|
|
|
|
|
|
|
|
2016-07-05 23:12:08 +02:00
|
|
|
@implementer(ICommentRemovedEvent)
|
2014-04-16 17:54:19 +02:00
|
|
|
class CommentRemovedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment is removed"""
|
2014-04-16 17:54:19 +02:00
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2016-07-05 23:12:08 +02:00
|
|
|
@implementer(IReplyAddedEvent)
|
2014-04-16 17:54:19 +02:00
|
|
|
class ReplyAddedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment reply is added"""
|
2014-04-16 17:54:19 +02:00
|
|
|
|
2015-05-03 08:22:51 +02:00
|
|
|
|
2021-09-08 13:02:34 +02:00
|
|
|
@implementer(IReplyModifiedEvent)
|
|
|
|
class ReplyModifiedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment reply is modified"""
|
2021-09-08 13:02:34 +02:00
|
|
|
|
|
|
|
|
2016-07-05 23:12:08 +02:00
|
|
|
@implementer(IReplyRemovedEvent)
|
2014-04-16 17:54:19 +02:00
|
|
|
class ReplyRemovedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment reply is removed"""
|
2018-09-27 11:26:41 +02:00
|
|
|
|
|
|
|
|
2018-10-24 16:49:22 +02:00
|
|
|
@implementer(ICommentDeletedEvent)
|
|
|
|
class CommentDeletedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment is deleted"""
|
2018-09-27 11:26:41 +02:00
|
|
|
|
|
|
|
|
2018-10-24 16:49:22 +02:00
|
|
|
@implementer(ICommentPublishedEvent)
|
|
|
|
class CommentPublishedEvent(DiscussionEvent):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Event to be triggered when a Comment is publicated"""
|
2019-12-08 20:01:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
@implementer(ICommentTransitionEvent)
|
|
|
|
class CommentTransitionEvent(DiscussionEvent):
|
|
|
|
"""Event to be triggered when a Comments review_state changed."""
|