plone.app.discussion/plone/app/discussion/events.py

75 lines
2.4 KiB
Python
Raw Permalink Normal View History

""" Custom discussion events
"""
from plone.app.discussion.interfaces import ICommentAddedEvent
from plone.app.discussion.interfaces import ICommentDeletedEvent
2022-05-01 23:14:00 +02:00
from plone.app.discussion.interfaces import ICommentModifiedEvent
from plone.app.discussion.interfaces import ICommentPublishedEvent
2022-05-01 23:14:00 +02:00
from plone.app.discussion.interfaces import ICommentRemovedEvent
from plone.app.discussion.interfaces import ICommentTransitionEvent
2022-05-01 23:14:00 +02:00
from plone.app.discussion.interfaces import IDiscussionEvent
from plone.app.discussion.interfaces import IReplyAddedEvent
from plone.app.discussion.interfaces import IReplyModifiedEvent
from plone.app.discussion.interfaces import IReplyRemovedEvent
from zope.interface import implementer
@implementer(IDiscussionEvent)
class DiscussionEvent:
2022-05-01 23:14:09 +02:00
"""Custom event"""
def __init__(self, context, comment, **kwargs):
self.object = context
self.comment = comment
for key, value in kwargs.items():
setattr(self, key, value)
# 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)
@implementer(ICommentAddedEvent)
class CommentAddedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment is added"""
@implementer(ICommentModifiedEvent)
class CommentModifiedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment is modified"""
@implementer(ICommentRemovedEvent)
class CommentRemovedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment is removed"""
@implementer(IReplyAddedEvent)
class ReplyAddedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment reply is added"""
@implementer(IReplyModifiedEvent)
class ReplyModifiedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment reply is modified"""
@implementer(IReplyRemovedEvent)
class ReplyRemovedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment reply is removed"""
@implementer(ICommentDeletedEvent)
class CommentDeletedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment is deleted"""
@implementer(ICommentPublishedEvent)
class CommentPublishedEvent(DiscussionEvent):
2022-05-01 23:14:09 +02:00
"""Event to be triggered when a Comment is publicated"""
@implementer(ICommentTransitionEvent)
class CommentTransitionEvent(DiscussionEvent):
"""Event to be triggered when a Comments review_state changed."""