in_response_to metadata added.

svn path=/plone.app.discussion/trunk/; revision=27789
This commit is contained in:
Timo Stollenwerk 2009-07-03 08:03:09 +00:00
parent d70d872f95
commit 072f903c3a
6 changed files with 19 additions and 9 deletions

View File

@ -116,7 +116,7 @@
<td tal:content="python:toLocalizedTime(item.ModificationDate, long_format=1)" /> <td tal:content="python:toLocalizedTime(item.ModificationDate, long_format=1)" />
<td> <td>
<a tal:attributes="href item/getURL" <a tal:attributes="href item/getURL"
tal:content="item/@@plone_context_state/parent|nothing" /> tal:content="item/in_response_to" />
</td> </td>
<td> <td>
<a tal:attributes="href item/getURL" <a tal:attributes="href item/getURL"

View File

@ -60,6 +60,10 @@ def description(object):
def searchable_text(object): def searchable_text(object):
return object.title, object.text return object.title, object.text
@indexer(IComment)
def in_response_to(object):
return object.__parent__.__parent__.title_or_id()
@indexer(IComment) @indexer(IComment)
def effective(object): def effective(object):
# the catalog index needs Zope DateTime instead of Python datetime # the catalog index needs Zope DateTime instead of Python datetime

View File

@ -63,6 +63,7 @@
<adapter name="total_comments" factory=".catalog.total_comments" /> <adapter name="total_comments" factory=".catalog.total_comments" />
<adapter name="last_comment_date" factory=".catalog.last_comment_date" /> <adapter name="last_comment_date" factory=".catalog.last_comment_date" />
<adapter name="commentators" factory=".catalog.commentators" /> <adapter name="commentators" factory=".catalog.commentators" />
<adapter name="in_response_to" factory=".catalog.in_response_to" />
<!-- comment indexes --> <!-- comment indexes -->
<adapter name="Title" factory=".catalog.title" /> <adapter name="Title" factory=".catalog.title" />

View File

@ -12,5 +12,6 @@
<column value="total_comments" /> <column value="total_comments" />
<column value="last_comment_date" /> <column value="last_comment_date" />
<column value="commentators" /> <column value="commentators" />
<column value="in_response_to" />
</object> </object>

View File

@ -22,6 +22,7 @@ class CatalogSetupTest(PloneTestCase):
self.failUnless('total_comments' in self.portal.portal_catalog.indexes()) self.failUnless('total_comments' in self.portal.portal_catalog.indexes())
self.failUnless('commentators' in self.portal.portal_catalog.indexes()) self.failUnless('commentators' in self.portal.portal_catalog.indexes())
self.failUnless('total_comments' in self.portal.portal_catalog.schema()) self.failUnless('total_comments' in self.portal.portal_catalog.schema())
self.failUnless('in_response_to' in self.portal.portal_catalog.schema())
def test_collection_criteria_installed(self): def test_collection_criteria_installed(self):
try: try:
@ -212,5 +213,10 @@ class CommentCatalogTest(PloneTestCase):
def test_creator(self): def test_creator(self):
self.assertEquals(self.comment_brain.Creator, 'Jim') self.assertEquals(self.comment_brain.Creator, 'Jim')
def test_in_response_to(self):
# make sure in_response_to returns the title or id of the content
# object the comment was added to
self.assertEquals(self.comment_brain.in_response_to, 'doc1')
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -144,14 +144,12 @@ class CommentIndexersTest(PloneTestCase):
def test_creator(self): def test_creator(self):
self.assertEquals(catalog.creator(self.comment)(), ('Jim')) self.assertEquals(catalog.creator(self.comment)(), ('Jim'))
def test_in_reply_to(self): def test_in_response_to(self):
pass # make sure in_response_to returns the title or id of the content
# object the comment was added to
def test_review_state(self): self.assertEquals(catalog.in_response_to(self.comment)(), 'doc1')
pass self.portal.doc1.title = 'Document 1'
self.assertEquals(catalog.in_response_to(self.comment)(), 'Document 1')
def test_object_provides(self):
pass
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)