Changes NotifyOnDelete to CommentDeletedEvent and NotifyOnPublish to CommentPublishedEvent for respect naming of event and interface

This commit is contained in:
Filippo Campi 2018-10-24 16:49:22 +02:00
parent 65b187ea53
commit 7bd62fa1cb
4 changed files with 18 additions and 18 deletions

View File

@ -3,8 +3,8 @@ from AccessControl import getSecurityManager
from AccessControl import Unauthorized from AccessControl import Unauthorized
from Acquisition import aq_inner from Acquisition import aq_inner
from Acquisition import aq_parent from Acquisition import aq_parent
from plone.app.discussion.events import NotifyOnPublish from plone.app.discussion.events import CommentPublishedEvent
from plone.app.discussion.events import NotifyOnDelete from plone.app.discussion.events import CommentDeletedEvent
from plone.app.discussion.interfaces import _ from plone.app.discussion.interfaces import _
from plone.app.discussion.interfaces import IComment from plone.app.discussion.interfaces import IComment
from plone.app.discussion.interfaces import IReplies from plone.app.discussion.interfaces import IReplies
@ -103,7 +103,7 @@ class DeleteComment(BrowserView):
if self.can_delete(comment): if self.can_delete(comment):
del conversation[comment.id] del conversation[comment.id]
content_object.reindexObject() content_object.reindexObject()
notify(NotifyOnDelete(self.context, comment)) notify(CommentDeletedEvent(self.context, comment))
IStatusMessage(self.context.REQUEST).addStatusMessage( IStatusMessage(self.context.REQUEST).addStatusMessage(
_('Comment deleted.'), _('Comment deleted.'),
type='info') type='info')
@ -187,7 +187,7 @@ class PublishComment(BrowserView):
workflowTool.doActionFor(comment, workflow_action) workflowTool.doActionFor(comment, workflow_action)
comment.reindexObject() comment.reindexObject()
content_object.reindexObject(idxs=['total_comments']) content_object.reindexObject(idxs=['total_comments'])
notify(NotifyOnPublish(self.context, comment)) notify(CommentPublishedEvent(self.context, comment))
IStatusMessage(self.context.REQUEST).addStatusMessage( IStatusMessage(self.context.REQUEST).addStatusMessage(
_('Comment approved.'), _('Comment approved.'),
type='info') type='info')
@ -263,7 +263,7 @@ class BulkActionsView(BrowserView):
workflowTool.doActionFor(comment, 'publish') workflowTool.doActionFor(comment, 'publish')
comment.reindexObject() comment.reindexObject()
content_object.reindexObject(idxs=['total_comments']) content_object.reindexObject(idxs=['total_comments'])
notify(NotifyOnPublish(content_object, comment)) notify(CommentPublishedEvent(content_object, comment))
def mark_as_spam(self): def mark_as_spam(self):
raise NotImplementedError raise NotImplementedError
@ -283,4 +283,4 @@ class BulkActionsView(BrowserView):
content_object = aq_parent(conversation) content_object = aq_parent(conversation)
del conversation[comment.id] del conversation[comment.id]
content_object.reindexObject(idxs=['total_comments']) content_object.reindexObject(idxs=['total_comments'])
notify(NotifyOnDelete(content_object, comment)) notify(CommentDeletedEvent(content_object, comment))

View File

@ -30,13 +30,13 @@
/> />
<interface <interface
interface="plone.app.discussion.interfaces.INotifyOnPublish" interface="plone.app.discussion.interfaces.ICommentPublishedEvent"
type="plone.contentrules.rule.interfaces.IRuleEventType" type="plone.contentrules.rule.interfaces.IRuleEventType"
name="Notify user on comment publication" name="Notify user on comment publication"
/> />
<interface <interface
interface="plone.app.discussion.interfaces.INotifyOnDelete" interface="plone.app.discussion.interfaces.ICommentDeletedEvent"
type="plone.contentrules.rule.interfaces.IRuleEventType" type="plone.contentrules.rule.interfaces.IRuleEventType"
name="Notify user on comment delete" name="Notify user on comment delete"
/> />
@ -68,12 +68,12 @@
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.INotifyOnDelete" for="plone.app.discussion.interfaces.ICommentDeletedEvent"
handler=".contentrules.execute_comment" handler=".contentrules.execute_comment"
/> />
<subscriber <subscriber
for="plone.app.discussion.interfaces.INotifyOnPublish" for="plone.app.discussion.interfaces.ICommentPublishedEvent"
handler=".contentrules.execute_comment" handler=".contentrules.execute_comment"
/> />

View File

@ -4,8 +4,8 @@
from plone.app.discussion.interfaces import ICommentAddedEvent from plone.app.discussion.interfaces import ICommentAddedEvent
from plone.app.discussion.interfaces import ICommentRemovedEvent from plone.app.discussion.interfaces import ICommentRemovedEvent
from plone.app.discussion.interfaces import IDiscussionEvent from plone.app.discussion.interfaces import IDiscussionEvent
from plone.app.discussion.interfaces import INotifyOnDelete from plone.app.discussion.interfaces import ICommentDeletedEvent
from plone.app.discussion.interfaces import INotifyOnPublish from plone.app.discussion.interfaces import ICommentPublishedEvent
from plone.app.discussion.interfaces import IReplyAddedEvent from plone.app.discussion.interfaces import IReplyAddedEvent
from plone.app.discussion.interfaces import IReplyRemovedEvent from plone.app.discussion.interfaces import IReplyRemovedEvent
from zope.interface import implementer from zope.interface import implementer
@ -52,13 +52,13 @@ class ReplyRemovedEvent(DiscussionEvent):
""" """
@implementer(INotifyOnDelete) @implementer(ICommentDeletedEvent)
class NotifyOnDelete(DiscussionEvent): class CommentDeletedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is deleted """ Event to be triggered when a Comment is deleted
""" """
@implementer(INotifyOnPublish) @implementer(ICommentPublishedEvent)
class NotifyOnPublish(DiscussionEvent): class CommentPublishedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is publicated """ Event to be triggered when a Comment is publicated
""" """

View File

@ -414,11 +414,11 @@ class IReplyRemovedEvent(IDiscussionEvent):
""" """
class INotifyOnPublish(IDiscussionEvent): class ICommentPublishedEvent(IDiscussionEvent):
""" Notify user on comment publication """ Notify user on comment publication
""" """
class INotifyOnDelete(IDiscussionEvent): class ICommentDeletedEvent(IDiscussionEvent):
""" Notify user on comment delete """ Notify user on comment delete
""" """