Show a 'Comments are moderated.' message next to the comment form if comments are moderated.

svn path=/plone.app.discussion/trunk/; revision=46782
This commit is contained in:
Timo Stollenwerk
2011-01-07 10:20:24 +00:00
parent b18469e5fd
commit c438743a3b
3 changed files with 38 additions and 4 deletions
+19 -2
View File
@@ -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):