Unless Discussion Item has an workflow, moderation is not enabled
svn path=/plone.app.discussion/trunk/; revision=49135
This commit is contained in:
		
							parent
							
								
									3a224784b0
								
							
						
					
					
						commit
						1a751b495f
					
				@ -39,12 +39,14 @@ class View(BrowserView):
 | 
			
		||||
        """
 | 
			
		||||
        context = aq_inner(self.context)
 | 
			
		||||
        workflowTool = getToolByName(context, 'portal_workflow')
 | 
			
		||||
        comment_workflow = workflowTool.getChainForPortalType('Discussion Item')[0]
 | 
			
		||||
        comment_workflow = workflowTool[comment_workflow]
 | 
			
		||||
        if 'pending' in comment_workflow.states:
 | 
			
		||||
            return True
 | 
			
		||||
        else:
 | 
			
		||||
            return False
 | 
			
		||||
        comment_workflow = workflowTool.getChainForPortalType('Discussion Item')
 | 
			
		||||
        if comment_workflow:
 | 
			
		||||
            comment_workflow = comment_workflow[0]
 | 
			
		||||
            comment_workflow = workflowTool[comment_workflow]
 | 
			
		||||
            if 'pending' in comment_workflow.states:
 | 
			
		||||
                return True
 | 
			
		||||
            else:
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ModerateCommentsEnabled(BrowserView):
 | 
			
		||||
@ -56,12 +58,14 @@ class ModerateCommentsEnabled(BrowserView):
 | 
			
		||||
        """
 | 
			
		||||
        context = aq_inner(self.context)
 | 
			
		||||
        workflowTool = getToolByName(context, 'portal_workflow', None)
 | 
			
		||||
        comment_workflow = workflowTool.getChainForPortalType('Discussion Item')[0]
 | 
			
		||||
        comment_workflow = workflowTool[comment_workflow]
 | 
			
		||||
        if 'pending' in comment_workflow.states:
 | 
			
		||||
            return True
 | 
			
		||||
        else:
 | 
			
		||||
            return
 | 
			
		||||
        comment_workflow = workflowTool.getChainForPortalType('Discussion Item')
 | 
			
		||||
        if comment_workflow:
 | 
			
		||||
            comment_workflow = comment_workflow[0]
 | 
			
		||||
            comment_workflow = workflowTool[comment_workflow]
 | 
			
		||||
            if 'pending' in comment_workflow.states:
 | 
			
		||||
                return True
 | 
			
		||||
            else:
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeleteComment(BrowserView):
 | 
			
		||||
 | 
			
		||||
@ -47,6 +47,9 @@ class ModerationViewTest(unittest.TestCase):
 | 
			
		||||
        """Make sure that moderation_enabled returns true if the comment
 | 
			
		||||
           workflow implements a 'pending' state.
 | 
			
		||||
        """
 | 
			
		||||
        # If workflow is not set, enabled must return False
 | 
			
		||||
        self.wf_tool.setChainForPortalTypes(('Discussion Item',),())
 | 
			
		||||
        self.assertEqual(self.view.moderation_enabled(), False)
 | 
			
		||||
        # The one_state_workflow does not have a 'pending' state
 | 
			
		||||
        self.wf_tool.setChainForPortalTypes(('Discussion Item',),
 | 
			
		||||
                                            ('one_state_workflow,'))
 | 
			
		||||
@ -77,7 +80,6 @@ class ModerationViewTest(unittest.TestCase):
 | 
			
		||||
        self.assertTrue('No comments to moderate' in view)
 | 
			
		||||
        self.assertEqual(len(self.view.comments), 0)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ModerationBulkActionsViewTest(unittest.TestCase):
 | 
			
		||||
 | 
			
		||||
    layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user