From 1e58aa63b1327b9c4e84027fdfd03c78287c098a Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Fri, 22 Jan 2010 19:02:41 +0000 Subject: [PATCH] fix CommentViewlet has_replies method. svn path=/plone.app.discussion/trunk/; revision=33282 --- plone/app/discussion/browser/comments.py | 8 ++++++-- plone/app/discussion/tests/test_comments_viewlet.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index ec1737b..fabd721 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -218,8 +218,12 @@ class CommentsViewlet(ViewletBase, layout.FormWrapper): """Returns true if there are replies. """ if self.get_replies(workflow_actions): - self.get_replies(workflow_actions).next() - return True + try: + self.get_replies(workflow_actions).next() + return True + except StopIteration: + pass + return False def get_replies(self, workflow_actions=False): """Returns all replies to a content object. diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 2007215..74a5045 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -134,13 +134,13 @@ class TestCommentsViewlet(PloneTestCase): self.failUnless(self.viewlet.is_discussion_allowed()) def test_has_replies(self): - self.failIf(self.viewlet.has_replies()) + self.assertEquals(self.viewlet.has_replies(), False) comment = createObject('plone.Comment') comment.title = 'Comment 1' comment.text = 'Comment text' conversation = IConversation(self.portal.doc1) conversation.addComment(comment) - self.failUnless(self.viewlet.has_replies()) + self.assertEquals(self.viewlet.has_replies(), True) def test_get_replies(self): self.failIf(self.viewlet.get_replies())