This commit is contained in:
Timo Stollenwerk 2013-04-18 15:38:17 +02:00
parent 0b8112fda1
commit 37faab444a

View File

@ -32,16 +32,18 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
schema = IDiscussionSettings schema = IDiscussionSettings
id = "DiscussionSettingsEditForm" id = "DiscussionSettingsEditForm"
label = _(u"Discussion settings") label = _(u"Discussion settings")
description = _(u"help_discussion_settings_editform", description = _(
u"help_discussion_settings_editform",
default=u"Some discussion related settings are not " default=u"Some discussion related settings are not "
"located in the Discussion Control Panel.\n" u"located in the Discussion Control Panel.\n"
"To enable comments for a specific content type, " u"To enable comments for a specific content type, "
"go to the Types Control Panel of this type and " u"go to the Types Control Panel of this type and "
"choose \"Allow comments\".\n" u"choose \"Allow comments\".\n"
"To enable the moderation workflow for comments, " u"To enable the moderation workflow for comments, "
"go to the Types Control Panel, choose " u"go to the Types Control Panel, choose "
"\"Comment\" and set workflow to " u"\"Comment\" and set workflow to "
"\"Comment Review Workflow\".") u"\"Comment Review Workflow\"."
)
def updateFields(self): def updateFields(self):
super(DiscussionSettingsEditForm, self).updateFields() super(DiscussionSettingsEditForm, self).updateFields()
@ -108,8 +110,10 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
output.append("globally_enabled") output.append("globally_enabled")
# Comment moderation # Comment moderation
if 'one_state_workflow' not in workflow_chain and \ one_state_worklow_disabled = 'one_state_workflow' not in workflow_chain
'comment_review_workflow' not in workflow_chain: comment_review_workflow_disabled = \
'comment_review_workflow' not in workflow_chain
if one_state_worklow_disabled and comment_review_workflow_disabled:
output.append("moderation_custom") output.append("moderation_custom")
elif settings.moderation_enabled: elif settings.moderation_enabled:
output.append("moderation_enabled") output.append("moderation_enabled")
@ -151,8 +155,10 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
""" """
wftool = getToolByName(self.context, "portal_workflow", None) wftool = getToolByName(self.context, "portal_workflow", None)
workflow_chain = wftool.getChainForPortalType('Discussion Item') workflow_chain = wftool.getChainForPortalType('Discussion Item')
if 'one_state_workflow' in workflow_chain \ one_state_workflow_enabled = 'one_state_workflow' in workflow_chain
or 'comment_review_workflow' in workflow_chain: comment_review_workflow_enabled = \
'comment_review_workflow' in workflow_chain
if one_state_workflow_enabled or comment_review_workflow_enabled:
return return
return True return True
@ -176,7 +182,7 @@ def notify_configuration_changed(event):
# Discussion control panel setting changed # Discussion control panel setting changed
if event.record.fieldName == 'moderation_enabled': if event.record.fieldName == 'moderation_enabled':
# Moderation enabled has changed # Moderation enabled has changed
if event.record.value == True: if event.record.value is True:
# Enable moderation workflow # Enable moderation workflow
wftool.setChainForPortalTypes(('Discussion Item',), wftool.setChainForPortalTypes(('Discussion Item',),
'comment_review_workflow') 'comment_review_workflow')