diff --git a/CHANGES.txt b/CHANGES.txt index 5035dfb..5c65aa3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 1.0b10 (unreleased) ------------------- +- Check the review_state to decide if moderation is enabled. If the current + comment workflow implements a 'pending' state, moderation is enabled. + [timo] + - Check the review_state instead of the workflow after a comment has been posted to decide if a message is shown to the user. This allows integrators to use custom review workflows. diff --git a/plone/app/discussion/browser/moderation.py b/plone/app/discussion/browser/moderation.py index 75c4306..eb663ff 100644 --- a/plone/app/discussion/browser/moderation.py +++ b/plone/app/discussion/browser/moderation.py @@ -61,13 +61,15 @@ class View(BrowserView): return text def moderation_enabled(self): - """Returns true if comment moderation workflow is - enabled on 'Discussion Item' content type. + """Returns true if a 'review workflow' is enabled on 'Discussion Item' + content type. A 'review workflow' is characterized by implementing + a 'pending' workflow state. """ context = aq_inner(self.context) wf_tool = getToolByName(context, 'portal_workflow') - if wf_tool.getChainForPortalType('Discussion Item') \ - == ('comment_review_workflow',): + comment_workflow = wf_tool.getChainForPortalType('Discussion Item')[0] + comment_workflow = wf_tool[comment_workflow] + if 'pending' in comment_workflow.states: return True else: return False diff --git a/plone/app/discussion/tests/test_moderation_view.py b/plone/app/discussion/tests/test_moderation_view.py index 12b1a52..aabd538 100644 --- a/plone/app/discussion/tests/test_moderation_view.py +++ b/plone/app/discussion/tests/test_moderation_view.py @@ -66,10 +66,17 @@ class ModerationViewTest(PloneTestCase): '++conversation++default/%s' % new_id_3) def test_moderation_enabled(self): - self.assertEquals(self.view.moderation_enabled(), True) + """Make sure that moderation_enabled returns true if the comment + workflow implements a 'pending' state. + """ + # The one_state_workflow does not have a 'pending' state self.wf_tool.setChainForPortalTypes(('Discussion Item',), - ('simple_publication_workflow,')) + ('one_state_workflow,')) self.assertEquals(self.view.moderation_enabled(), False) + # The comment_review_workflow does have a 'pending' state + self.wf_tool.setChainForPortalTypes(('Discussion Item',), + ('comment_review_workflow,')) + self.assertEquals(self.view.moderation_enabled(), True) def test_old_comments_not_shown_in_moderation_view(self): # Create an old comment and make sure it is not shown