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:
parent
2e004456f5
commit
adb0390227
@ -9,6 +9,8 @@ from Products.CMFPlone import PloneMessageFactory as _
|
|||||||
|
|
||||||
from Products.statusmessages.interfaces import IStatusMessage
|
from Products.statusmessages.interfaces import IStatusMessage
|
||||||
|
|
||||||
|
from plone.app.discussion.interfaces import IComment
|
||||||
|
|
||||||
class View(BrowserView):
|
class View(BrowserView):
|
||||||
"""Moderation View
|
"""Moderation View
|
||||||
"""
|
"""
|
||||||
@ -28,7 +30,7 @@ class View(BrowserView):
|
|||||||
|
|
||||||
catalog = getToolByName(context, 'portal_catalog')
|
catalog = getToolByName(context, 'portal_catalog')
|
||||||
|
|
||||||
self.comments = catalog(portal_type='Discussion Item',
|
self.comments = catalog(object_provides=IComment.__identifier__,
|
||||||
review_state='pending',
|
review_state='pending',
|
||||||
sort_on='created',
|
sort_on='created',
|
||||||
sort_order='reverse')
|
sort_order='reverse')
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from DateTime import DateTime
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from plone.registry import Registry
|
from plone.registry import Registry
|
||||||
@ -30,6 +32,7 @@ class ModerationViewTest(PloneTestCase):
|
|||||||
self.loginAsPortalOwner()
|
self.loginAsPortalOwner()
|
||||||
typetool = self.portal.portal_types
|
typetool = self.portal.portal_types
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
typetool.constructContent('Document', self.portal, 'doc1')
|
||||||
|
|
||||||
self.portal_discussion = getToolByName(self.portal,
|
self.portal_discussion = getToolByName(self.portal,
|
||||||
'portal_discussion',
|
'portal_discussion',
|
||||||
None)
|
None)
|
||||||
@ -77,6 +80,28 @@ class ModerationViewTest(PloneTestCase):
|
|||||||
('simple_publication_workflow,'))
|
('simple_publication_workflow,'))
|
||||||
self.assertEquals(self.view.moderation_enabled(), False)
|
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():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
Loading…
Reference in New Issue
Block a user