Show "moderate comments" link in the admin panel only if a moderation workflow is enabled for comments.

svn path=/plone.app.discussion/trunk/; revision=46206
This commit is contained in:
Timo Stollenwerk
2010-12-08 17:45:11 +00:00
parent 6e354718f4
commit 583b25530e
4 changed files with 39 additions and 1 deletions
@@ -54,6 +54,23 @@
permission="plone.app.discussion.ReviewComments"
/>
<!-- Moderate comments enabled view -->
<browser:page
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
name="moderate-comments-enabled"
layer="..interfaces.IDiscussionLayer"
class=".moderation.ModerateCommentsEnabled"
permission="zope2.View"
/>
<browser:page
for="plone.app.layout.navigation.interfaces.INavigationRoot"
name="moderate-comments-enabled"
layer="..interfaces.IDiscussionLayer"
class=".moderation.ModerateCommentsEnabled"
permission="zope2.View"
/>
<!-- Delete comment view -->
<browser:page
for="plone.app.discussion.interfaces.IComment"
@@ -75,6 +75,23 @@ class View(BrowserView):
return False
class ModerateCommentsEnabled(BrowserView):
def __call__(self):
"""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', None)
comment_workflow = wf_tool.getChainForPortalType('Discussion Item')[0]
comment_workflow = wf_tool[comment_workflow]
if 'pending' in comment_workflow.states:
return True
else:
return
class DeleteComment(BrowserView):
"""Delete a comment from a conversation.