diff --git a/CHANGES.txt b/CHANGES.txt index a397447..509ce8b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 1.0RC1 (unreleased) ------------------- +- Show a 'Comments are moderated.' message next to the comment form if comments + are moderated. + [timo] + - Make sure plone.app.registry's ZCML is loaded, so that its import step will run when plone.app.discussion is installed. [davisagli] diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 31a6226..0c2a9e4 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -59,6 +59,10 @@ COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _( "Plain text formatting. Web and email addresses are transformed " + "into clickable links.") +COMMENT_DESCRIPTION_MODERATION_ENABLED = _( + u"comment_description_moderation_enabled", + default=u"Comments are moderated.") + class CommentForm(extensible.ExtensibleForm, form.Form): @@ -296,16 +300,29 @@ class CommentsViewlet(ViewletBase): def comment_transform_message(self): """Returns the description that shows up above the comment text, - dependent on the text_transform setting of the discussion control - panel. + dependent on the text_transform setting and the comment moderation + workflow in the discussion control panel. """ + context = aq_inner(self.context) registry = queryUtility(IRegistry) settings = registry.forInterface(IDiscussionSettings, check=False) + # text transform setting if settings.text_transform == "text/x-web-intelligent": message = translate(Message(COMMENT_DESCRIPTION_INTELLIGENT_TEXT)) else: message = translate(Message(COMMENT_DESCRIPTION_PLAIN_TEXT)) + + # comment workflow + wftool = getToolByName(context, "portal_workflow", None) + comment_workflow = wftool.getChainForPortalType('Discussion Item')[0] + comment_workflow = wftool[comment_workflow] + # check if the current workflow implements a pending state. If this is + # true comments are moderated + if 'pending' in comment_workflow.states: + message = message + " " + \ + translate(Message(COMMENT_DESCRIPTION_MODERATION_ENABLED)) + return message def has_replies(self, workflow_actions=False): diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index a7e5f4f..2160605 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -295,7 +295,8 @@ class TestCommentsViewlet(PloneTestCase): self.failUnless(self.viewlet.is_discussion_allowed()) def test_comment_transform_message(self): - # Default transform is plain/text + + # Default transform is plain/text and comment moderation disabled self.failUnless(self.viewlet.comment_transform_message()) self.assertEquals( self.viewlet.comment_transform_message(), @@ -307,12 +308,24 @@ class TestCommentsViewlet(PloneTestCase): settings = registry.forInterface(IDiscussionSettings, check=False) settings.text_transform = "text/x-web-intelligent" - # Make sure the comment description is changes accordingly + # Make sure the comment description changes accordingly self.assertEquals( self.viewlet.comment_transform_message(), "You can add a comment by filling out the form below. " + "Plain text formatting. Web and email addresses are transformed " + "into clickable links.") + + # Enable moderation workflow + self.portal.portal_workflow.setChainForPortalTypes( + ('Discussion Item',), + ('comment_review_workflow,')) + + # Make sure the comment description shows that comments are moderated + self.assertEquals( + self.viewlet.comment_transform_message(), + "You can add a comment by filling out the form below. " + + "Plain text formatting. Web and email addresses are transformed " + + "into clickable links. Comments are moderated.") def test_has_replies(self): self.assertEquals(self.viewlet.has_replies(), False)