use object_provides instead of portal_type to query the catalog for comments. this fixes bug #2010085;

svn path=/plone.app.discussion/trunk/; revision=32538
This commit is contained in:
Timo Stollenwerk 2009-12-19 15:03:12 +00:00
parent 2e004456f5
commit adb0390227
2 changed files with 28 additions and 1 deletions

View File

@ -9,6 +9,8 @@ from Products.CMFPlone import PloneMessageFactory as _
from Products.statusmessages.interfaces import IStatusMessage
from plone.app.discussion.interfaces import IComment
class View(BrowserView):
"""Moderation View
"""
@ -28,7 +30,7 @@ class View(BrowserView):
catalog = getToolByName(context, 'portal_catalog')
self.comments = catalog(portal_type='Discussion Item',
self.comments = catalog(object_provides=IComment.__identifier__,
review_state='pending',
sort_on='created',
sort_order='reverse')

View File

@ -1,4 +1,6 @@
import unittest
from DateTime import DateTime
from datetime import datetime, timedelta
from plone.registry import Registry
@ -30,6 +32,7 @@ class ModerationViewTest(PloneTestCase):
self.loginAsPortalOwner()
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
self.portal_discussion = getToolByName(self.portal,
'portal_discussion',
None)
@ -77,6 +80,28 @@ class ModerationViewTest(PloneTestCase):
('simple_publication_workflow,'))
self.assertEquals(self.view.moderation_enabled(), False)
def test_old_comments_not_shown_in_moderation_view(self):
# Create an old comment and make sure it is not shown
# in the moderation view.
# Create old comment
discussion = getToolByName(self.portal, 'portal_discussion', None)
discussion.overrideDiscussionFor(self.portal.doc1, 1)
talkback = discussion.getDiscussionFor(self.portal.doc1)
self.portal.doc1.talkback.createReply('My Title', 'My Text', Creator='Jim')
reply = talkback.getReplies()[0]
reply.setReplyTo(self.portal.doc1)
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6)
reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7)
self.assertEquals(reply.Title(), 'My Title')
self.assertEquals(reply.EditableBody(), 'My Text')
self.failUnless('Jim' in reply.listCreators())
self.assertEquals(talkback.replyCount(self.portal.doc1), 1)
self.assertEquals(reply.inReplyTo(), self.portal.doc1)
# Make sure only the two new comments are shown
self.view()
self.assertEquals(len(self.view.comments), 3)
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)