Merge pull request #140 from RedTurtle/filippo_moderation_js
Notify on comments moderation
This commit is contained in:
commit
25e85a980d
@ -10,7 +10,8 @@ Breaking changes:
|
|||||||
|
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
- *add item here*
|
- Added notification about the publishing or elimination of a comment.
|
||||||
|
[eikichi18]
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ from plone.app.registry.browser import controlpanel
|
|||||||
from plone.registry.interfaces import IRecordModifiedEvent
|
from plone.registry.interfaces import IRecordModifiedEvent
|
||||||
from plone.registry.interfaces import IRegistry
|
from plone.registry.interfaces import IRegistry
|
||||||
from Products.CMFCore.utils import getToolByName
|
from Products.CMFCore.utils import getToolByName
|
||||||
from Products.CMFPlone.interfaces.controlpanel import IConfigurationChangedEvent # noqa: E501
|
|
||||||
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
|
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
|
||||||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
||||||
from Products.statusmessages.interfaces import IStatusMessage
|
from Products.statusmessages.interfaces import IStatusMessage
|
||||||
@ -17,6 +16,13 @@ from zope.component import getUtility
|
|||||||
from zope.component import queryUtility
|
from zope.component import queryUtility
|
||||||
from zope.component.hooks import getSite
|
from zope.component.hooks import getSite
|
||||||
|
|
||||||
|
# try/except was added because Configuration Changed Event was moved inside the
|
||||||
|
# controlpanel file in the PR #2495 on Products.CMFPlone
|
||||||
|
try:
|
||||||
|
from Products.CMFPlone.interfaces.controlpanel import IConfigurationChangedEvent # noqa: E501
|
||||||
|
except ImportError:
|
||||||
|
from Products.CMFPlone.interfaces import IConfigurationChangedEvent
|
||||||
|
|
||||||
|
|
||||||
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
||||||
"""Discussion settings form.
|
"""Discussion settings form.
|
||||||
|
@ -3,6 +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 CommentPublishedEvent
|
||||||
|
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
|
||||||
@ -10,6 +12,7 @@ from Products.CMFCore.utils import getToolByName
|
|||||||
from Products.Five.browser import BrowserView
|
from Products.Five.browser import BrowserView
|
||||||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
||||||
from Products.statusmessages.interfaces import IStatusMessage
|
from Products.statusmessages.interfaces import IStatusMessage
|
||||||
|
from zope.event import notify
|
||||||
|
|
||||||
|
|
||||||
class View(BrowserView):
|
class View(BrowserView):
|
||||||
@ -100,6 +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(CommentDeletedEvent(self.context, comment))
|
||||||
IStatusMessage(self.context.REQUEST).addStatusMessage(
|
IStatusMessage(self.context.REQUEST).addStatusMessage(
|
||||||
_('Comment deleted.'),
|
_('Comment deleted.'),
|
||||||
type='info')
|
type='info')
|
||||||
@ -183,6 +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(CommentPublishedEvent(self.context, comment))
|
||||||
IStatusMessage(self.context.REQUEST).addStatusMessage(
|
IStatusMessage(self.context.REQUEST).addStatusMessage(
|
||||||
_('Comment approved.'),
|
_('Comment approved.'),
|
||||||
type='info')
|
type='info')
|
||||||
@ -258,6 +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(CommentPublishedEvent(content_object, comment))
|
||||||
|
|
||||||
def mark_as_spam(self):
|
def mark_as_spam(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -277,3 +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(CommentDeletedEvent(content_object, comment))
|
||||||
|
@ -28,6 +28,18 @@
|
|||||||
type="plone.contentrules.rule.interfaces.IRuleEventType"
|
type="plone.contentrules.rule.interfaces.IRuleEventType"
|
||||||
name="Comment reply removed"
|
name="Comment reply removed"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<interface
|
||||||
|
interface="plone.app.discussion.interfaces.ICommentPublishedEvent"
|
||||||
|
type="plone.contentrules.rule.interfaces.IRuleEventType"
|
||||||
|
name="Notify user on comment publication"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<interface
|
||||||
|
interface="plone.app.discussion.interfaces.ICommentDeletedEvent"
|
||||||
|
type="plone.contentrules.rule.interfaces.IRuleEventType"
|
||||||
|
name="Notify user on comment delete"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
||||||
@ -54,6 +66,16 @@
|
|||||||
for="plone.app.discussion.interfaces.IReplyRemovedEvent"
|
for="plone.app.discussion.interfaces.IReplyRemovedEvent"
|
||||||
handler=".contentrules.execute_comment"
|
handler=".contentrules.execute_comment"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<subscriber
|
||||||
|
for="plone.app.discussion.interfaces.ICommentDeletedEvent"
|
||||||
|
handler=".contentrules.execute_comment"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<subscriber
|
||||||
|
for="plone.app.discussion.interfaces.ICommentPublishedEvent"
|
||||||
|
handler=".contentrules.execute_comment"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
||||||
|
@ -4,6 +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 ICommentDeletedEvent
|
||||||
|
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
|
||||||
@ -48,3 +50,15 @@ class ReplyAddedEvent(DiscussionEvent):
|
|||||||
class ReplyRemovedEvent(DiscussionEvent):
|
class ReplyRemovedEvent(DiscussionEvent):
|
||||||
""" Event to be triggered when a Comment reply is removed
|
""" Event to be triggered when a Comment reply is removed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ICommentDeletedEvent)
|
||||||
|
class CommentDeletedEvent(DiscussionEvent):
|
||||||
|
""" Event to be triggered when a Comment is deleted
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ICommentPublishedEvent)
|
||||||
|
class CommentPublishedEvent(DiscussionEvent):
|
||||||
|
""" Event to be triggered when a Comment is publicated
|
||||||
|
"""
|
||||||
|
@ -412,3 +412,13 @@ class IReplyAddedEvent(IDiscussionEvent):
|
|||||||
class IReplyRemovedEvent(IDiscussionEvent):
|
class IReplyRemovedEvent(IDiscussionEvent):
|
||||||
""" Comment reply removed
|
""" Comment reply removed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ICommentPublishedEvent(IDiscussionEvent):
|
||||||
|
""" Notify user on comment publication
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ICommentDeletedEvent(IDiscussionEvent):
|
||||||
|
""" Notify user on comment delete
|
||||||
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user