indexes for IComment added to override the IConversation indexes.
svn path=/plone.app.discussion/trunk/; revision=27838
This commit is contained in:
parent
fa2f961ebe
commit
a946fb54fa
@ -12,17 +12,15 @@ from Products.CMFCore.interfaces import IContentish
|
|||||||
|
|
||||||
from Products.ZCatalog.interfaces import IZCatalog
|
from Products.ZCatalog.interfaces import IZCatalog
|
||||||
|
|
||||||
from plone.indexer import indexer
|
|
||||||
|
|
||||||
from plone.app.discussion.interfaces import IConversation, IComment
|
from plone.app.discussion.interfaces import IConversation, IComment
|
||||||
|
|
||||||
|
from plone.indexer import indexer
|
||||||
|
from plone.indexer.interfaces import IIndexer
|
||||||
|
|
||||||
MAX_DESCRIPTION=25
|
MAX_DESCRIPTION=25
|
||||||
|
|
||||||
# Conversation Indexers
|
# Conversation Indexers
|
||||||
|
|
||||||
from plone.indexer.interfaces import IIndexer
|
|
||||||
|
|
||||||
@indexer(IContentish, IZCatalog)
|
@indexer(IContentish, IZCatalog)
|
||||||
def total_comments(object):
|
def total_comments(object):
|
||||||
conversation = IConversation(object)
|
conversation = IConversation(object)
|
||||||
@ -89,3 +87,17 @@ def modified(object):
|
|||||||
object.modification_date.hour,
|
object.modification_date.hour,
|
||||||
object.modification_date.minute,
|
object.modification_date.minute,
|
||||||
object.modification_date.second)
|
object.modification_date.second)
|
||||||
|
|
||||||
|
# Override the conversation indexers for comments
|
||||||
|
|
||||||
|
@indexer(IComment)
|
||||||
|
def comments_total_comments(object):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@indexer(IComment)
|
||||||
|
def comments_last_comment_date(object):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@indexer(IComment)
|
||||||
|
def comments_commentators(object):
|
||||||
|
return None
|
||||||
|
@ -85,5 +85,8 @@
|
|||||||
<adapter name="effective" factory=".catalog.effective" />
|
<adapter name="effective" factory=".catalog.effective" />
|
||||||
<adapter name="created" factory=".catalog.created" />
|
<adapter name="created" factory=".catalog.created" />
|
||||||
<adapter name="modified" factory=".catalog.modified" />
|
<adapter name="modified" factory=".catalog.modified" />
|
||||||
|
<adapter name="total_comments" factory=".catalog.comments_total_comments" />
|
||||||
|
<adapter name="last_comment_date" factory=".catalog.comments_last_comment_date" />
|
||||||
|
<adapter name="commentators" factory=".catalog.comments_commentators" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
@ -64,6 +64,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
path = {'query' : '/'.join(self.portal.doc1.getPhysicalPath()) },
|
path = {'query' : '/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||||
portal_type = "Document"
|
portal_type = "Document"
|
||||||
)
|
)
|
||||||
|
self.brains = brains
|
||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
self.conversation_brain = brains[0]
|
self.conversation_brain = brains[0]
|
||||||
self.comment1 = comment1
|
self.comment1 = comment1
|
||||||
@ -171,6 +172,16 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
conversation_brain = brains[0]
|
conversation_brain = brains[0]
|
||||||
self.assertEquals(conversation_brain.commentators, ())
|
self.assertEquals(conversation_brain.commentators, ())
|
||||||
|
|
||||||
|
def test_conversation_indexes_not_in_comments(self):
|
||||||
|
brains = self.catalog.searchResults(
|
||||||
|
path = {'query' : '/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||||
|
portal_type = "Discussion Item"
|
||||||
|
)
|
||||||
|
comment1_brain = brains[0]
|
||||||
|
self.assertEquals(comment1_brain.commentators, None)
|
||||||
|
self.assertEquals(comment1_brain.last_comment_date, None)
|
||||||
|
self.assertEquals(comment1_brain.total_comments, None)
|
||||||
|
|
||||||
class CommentCatalogTest(PloneTestCase):
|
class CommentCatalogTest(PloneTestCase):
|
||||||
|
|
||||||
layer = DiscussionLayer
|
layer = DiscussionLayer
|
||||||
|
Loading…
Reference in New Issue
Block a user