From dc948da00ba32e6fe76b7a023639052ad5ebb5cb Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Mon, 1 Jun 2009 23:29:09 +0000 Subject: [PATCH] creator index added. svn path=/plone.app.discussion/trunk/; revision=27258 --- plone/app/discussion/catalog.py | 4 ++++ plone/app/discussion/configure.zcml | 1 + plone/app/discussion/tests/test_indexers.py | 20 +++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index ed6caf9..e052ca9 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -18,6 +18,10 @@ MAX_DESCRIPTION=25 def comment_title(object): return object.title +@indexer(IComment) +def comment_creator(object): + return object.creator + @indexer(IComment) def comment_description(object): # Return the first 25 words of the comment text and append '...' diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 4b7b01f..21865d9 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -59,6 +59,7 @@ + diff --git a/plone/app/discussion/tests/test_indexers.py b/plone/app/discussion/tests/test_indexers.py index b0531d9..1172bc6 100644 --- a/plone/app/discussion/tests/test_indexers.py +++ b/plone/app/discussion/tests/test_indexers.py @@ -118,7 +118,25 @@ class IndexersTest(PloneTestCase): self.assert_(isinstance(catalog.comment_searchable_text, DelegatingIndexerFactory)) def test_creator(self): - pass + # Create a conversation. In this case we doesn't assign it to an + # object, as we just want to check the Conversation object API. + conversation = IConversation(self.portal.doc1) + + # Pretend that we have traversed to the comment by aq wrapping it. + conversation = conversation.__of__(self.portal.doc1) + + # Add a comment. Note: in real life, we always create comments via the factory + # to allow different factories to be swapped in + + comment = createObject('plone.Comment') + comment.title = 'Comment 1' + comment.text = 'Comment text' + comment.creator = "Jim" + + new_id = conversation.addComment(comment) + + self.assertEquals(catalog.comment_creator(comment)(), ('Jim')) + def test_title(self): pass