Reindex comments when they are modified
This commit is contained in:
parent
608287692c
commit
26a21a12d5
@ -10,7 +10,8 @@ Breaking changes:
|
||||
|
||||
New features:
|
||||
|
||||
- *add item here*
|
||||
- Reindex comments when they are modified.
|
||||
[gforcada]
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
@ -12,6 +12,8 @@ from Products.statusmessages.interfaces import IStatusMessage
|
||||
from z3c.form import button
|
||||
from zope.component import getMultiAdapter
|
||||
from zope.component import getUtility
|
||||
from zope.event import notify
|
||||
from zope.lifecycleevent import ObjectModifiedEvent
|
||||
|
||||
|
||||
class View(BrowserView):
|
||||
@ -91,6 +93,8 @@ class EditCommentForm(CommentForm):
|
||||
|
||||
# Update text
|
||||
self.context.text = data['text']
|
||||
# Notify that the object has been modified
|
||||
notify(ObjectModifiedEvent(self.context))
|
||||
|
||||
# Redirect to comment
|
||||
IStatusMessage(self.request).add(_(u'comment_edit_notification',
|
||||
|
@ -3,7 +3,7 @@ from Products.CMFCore.utils import getToolByName
|
||||
|
||||
|
||||
def index_object(obj, event):
|
||||
"""Index the object when it is added to the conversation.
|
||||
"""Index the object when it is added/modified to the conversation.
|
||||
"""
|
||||
catalog = getToolByName(obj, 'portal_catalog')
|
||||
return catalog.reindexObject(obj)
|
||||
|
@ -39,6 +39,12 @@
|
||||
handler=".subscribers.index_object"
|
||||
/>
|
||||
|
||||
<subscriber
|
||||
for="plone.app.discussion.interfaces.IComment
|
||||
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
|
||||
handler=".subscribers.index_object"
|
||||
/>
|
||||
|
||||
<subscriber
|
||||
for="plone.app.discussion.interfaces.IComment
|
||||
zope.lifecycleevent.interfaces.IObjectRemovedEvent"
|
||||
|
@ -9,6 +9,8 @@ from plone.app.testing import TEST_USER_ID
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from zope.annotation.interfaces import IAnnotations
|
||||
from zope.component import createObject
|
||||
from zope.event import notify
|
||||
from zope.lifecycleevent import ObjectModifiedEvent
|
||||
|
||||
import transaction
|
||||
import unittest2 as unittest
|
||||
@ -329,6 +331,13 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
))
|
||||
self.assertEqual(len(brains), 0)
|
||||
|
||||
def test_reindex_comment(self):
|
||||
# Make sure a comment is reindexed on the catalog when is modified
|
||||
self.comment.text = 'Another text'
|
||||
notify(ObjectModifiedEvent(self.comment))
|
||||
brains = self.catalog.searchResults(SearchableText='Another text')
|
||||
self.assertEqual(len(brains), 1)
|
||||
|
||||
def test_remove_comments_when_content_object_is_removed(self):
|
||||
"""Make sure all comments are removed from the catalog, if the content
|
||||
object is removed.
|
||||
|
Loading…
Reference in New Issue
Block a user