Do not show "publish" bulk action in moderation view when moderation is disabled. Fix story 1105355
. svn path=/plone.app.discussion/trunk/; revision=30678
This commit is contained in:
parent
c9a31ee978
commit
58f8f4bf22
@ -14,7 +14,8 @@
|
||||
Batch python:modules['Products.CMFPlone'].Batch;
|
||||
b_size python:30;
|
||||
b_start python:0;
|
||||
b_start request/b_start | b_start;">
|
||||
b_start request/b_start | b_start;
|
||||
moderation_enabled view/moderation_enabled;">
|
||||
|
||||
<h1 class="documentFirstHeading" i18n:translate="title_review">
|
||||
Moderate comments
|
||||
@ -79,7 +80,7 @@
|
||||
<!--<option value="retract" i18n:translate="bulkactions_retract">Retract</option>-->
|
||||
<option value="publish"
|
||||
i18n:translate="bulkactions_publish"
|
||||
tal:condition="python: filter != 'published'">Publish</option>
|
||||
tal:condition="python: filter != 'published' and moderation_enabled">Publish</option>
|
||||
<!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>-->
|
||||
<option value="delete" i18n:translate="bulkactions_delete">Delete</option>
|
||||
</select>
|
||||
|
@ -41,8 +41,21 @@ class View(BrowserView):
|
||||
def cook(self, text):
|
||||
return text
|
||||
|
||||
def comments_all(self, start=0, size=None):
|
||||
def moderation_enabled(self):
|
||||
"""Returns true if comment moderation workflow is
|
||||
enabled on 'Discussion Item' content type.
|
||||
"""
|
||||
context = aq_inner(self.context)
|
||||
wf_tool = getToolByName(context, 'portal_workflow')
|
||||
if wf_tool.getChainForPortalType('Discussion Item') \
|
||||
== ('comment_review_workflow',):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def comments_all(self, start=0, size=None):
|
||||
"""Returns all comments.
|
||||
"""
|
||||
self.state = self.request.get('review_state', 'pending')
|
||||
self.transition = self.request.get('publish_transition', 'publish')
|
||||
self.limit = self.request.get('limit', 100)
|
||||
@ -57,6 +70,8 @@ class View(BrowserView):
|
||||
)
|
||||
|
||||
def comments_pending(self, start=0, size=None):
|
||||
"""Returns all comments with 'pending' review state.
|
||||
"""
|
||||
self.state = self.request.get('review_state', 'pending')
|
||||
self.transition = self.request.get('publish_transition', 'publish')
|
||||
self.limit = self.request.get('limit', 100)
|
||||
@ -72,7 +87,8 @@ class View(BrowserView):
|
||||
)
|
||||
|
||||
def comments_published(self, start=0, size=None):
|
||||
|
||||
"""Returns all comments with 'published' review state.
|
||||
"""
|
||||
self.state = self.request.get('review_state', 'pending')
|
||||
self.transition = self.request.get('publish_transition', 'pending')
|
||||
self.limit = self.request.get('limit', 100)
|
||||
@ -88,8 +104,13 @@ class View(BrowserView):
|
||||
)
|
||||
|
||||
def comments_spam(self, start=0, size=None):
|
||||
"""Returns all comments that are marked as spam.
|
||||
|
||||
Not implemented yet.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
class DeleteComment(BrowserView):
|
||||
"""Delete a comment from a conversation
|
||||
"""
|
||||
|
@ -17,7 +17,8 @@ from Products.CMFPlone.tests import dummy
|
||||
from Products.PloneTestCase.ptc import PloneTestCase
|
||||
|
||||
from plone.app.discussion.browser.moderation import View
|
||||
from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings
|
||||
from plone.app.discussion.interfaces import IConversation, IComment
|
||||
from plone.app.discussion.interfaces import IReplies, IDiscussionSettings
|
||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||
|
||||
|
||||
@ -29,13 +30,17 @@ class ModerationViewTest(PloneTestCase):
|
||||
self.loginAsPortalOwner()
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None)
|
||||
self.membership_tool = getToolByName(self.folder, 'portal_membership')
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
None)
|
||||
self.membership_tool = getToolByName(self.folder,
|
||||
'portal_membership')
|
||||
self.memberdata = self.portal.portal_memberdata
|
||||
request = self.app.REQUEST
|
||||
context = getattr(self.portal, 'doc1')
|
||||
self.view = View(context, request)
|
||||
self.portal.portal_workflow.setChainForPortalTypes(('Discussion Item',), 'comment_review_workflow')
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',), 'comment_review_workflow')
|
||||
self.wf_tool = self.portal.portal_workflow
|
||||
|
||||
# Add a conversation with three comments
|
||||
@ -47,21 +52,30 @@ class ModerationViewTest(PloneTestCase):
|
||||
comment1.text = 'Comment text'
|
||||
comment1.Creator = 'Jim'
|
||||
new_id_1 = conversation.addComment(comment1)
|
||||
self.comment1 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_1)
|
||||
self.comment1 = self.portal.doc1.restrictedTraverse(\
|
||||
'++conversation++default/%s' % new_id_1)
|
||||
|
||||
comment2 = createObject('plone.Comment')
|
||||
comment2.title = 'Comment 2'
|
||||
comment2.text = 'Comment text'
|
||||
comment2.Creator = 'Joe'
|
||||
new_id_2 = conversation.addComment(comment2)
|
||||
self.comment2 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_2)
|
||||
self.comment2 = self.portal.doc1.restrictedTraverse(\
|
||||
'++conversation++default/%s' % new_id_2)
|
||||
|
||||
comment3 = createObject('plone.Comment')
|
||||
comment3.title = 'Comment 3'
|
||||
comment3.text = 'Comment text'
|
||||
comment3.Creator = 'Emma'
|
||||
new_id_3 = conversation.addComment(comment3)
|
||||
self.comment3 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_3)
|
||||
self.comment3 = self.portal.doc1.restrictedTraverse(\
|
||||
'++conversation++default/%s' % new_id_3)
|
||||
|
||||
def test_moderation_enabled(self):
|
||||
self.assertEquals(self.view.moderation_enabled(), True)
|
||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
||||
('simple_publication_workflow,'))
|
||||
self.assertEquals(self.view.moderation_enabled(), False)
|
||||
|
||||
def test_comments_all(self):
|
||||
self.failUnless(self.view.comments_all())
|
||||
@ -71,7 +85,8 @@ class ModerationViewTest(PloneTestCase):
|
||||
self.wf_tool.getInfoFor(self.comment1, 'review_state')
|
||||
self.failUnless(self.view.comments_pending())
|
||||
self.assertEquals(len(self.view.comments_pending()), 3)
|
||||
self.portal.portal_workflow.doActionFor(self.comment1, action='publish')
|
||||
self.portal.portal_workflow.doActionFor(self.comment1,
|
||||
action='publish')
|
||||
#self.comment1.reindexObject()
|
||||
#self.assertEquals(len(self.view.comments_pending()), 2)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user