"Enable comment moderation" setting added to the discussion control panel. Just a proof of concept so far. Not fully implemented yet. No tests.
svn path=/plone.app.discussion/trunk/; revision=46249
This commit is contained in:
parent
09a804aa88
commit
0475376ed0
@ -40,6 +40,8 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
|||||||
super(DiscussionSettingsEditForm, self).updateFields()
|
super(DiscussionSettingsEditForm, self).updateFields()
|
||||||
self.fields['globally_enabled'].widgetFactory = \
|
self.fields['globally_enabled'].widgetFactory = \
|
||||||
SingleCheckBoxFieldWidget
|
SingleCheckBoxFieldWidget
|
||||||
|
self.fields['moderation_enabled'].widgetFactory = \
|
||||||
|
SingleCheckBoxFieldWidget
|
||||||
self.fields['anonymous_comments'].widgetFactory = \
|
self.fields['anonymous_comments'].widgetFactory = \
|
||||||
SingleCheckBoxFieldWidget
|
SingleCheckBoxFieldWidget
|
||||||
self.fields['show_commenter_image'].widgetFactory = \
|
self.fields['show_commenter_image'].widgetFactory = \
|
||||||
@ -97,6 +99,8 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
|
|||||||
if settings.globally_enabled:
|
if settings.globally_enabled:
|
||||||
output.append("globally_enabled")
|
output.append("globally_enabled")
|
||||||
|
|
||||||
|
# Comment moderation
|
||||||
|
|
||||||
# Anonymous comments
|
# Anonymous comments
|
||||||
if settings.anonymous_comments:
|
if settings.anonymous_comments:
|
||||||
output.append("anonymous_comments")
|
output.append("anonymous_comments")
|
||||||
@ -128,3 +132,30 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
|
|||||||
if mailhost and email:
|
if mailhost and email:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def notify_configuration_changed(event):
|
||||||
|
"""Event subscriber that is called every time the configuration changed.
|
||||||
|
"""
|
||||||
|
from zope.app.component.hooks import getSite
|
||||||
|
portal = getSite()
|
||||||
|
wftool = getToolByName(portal, 'portal_workflow', None)
|
||||||
|
from plone.registry.interfaces import IRecordModifiedEvent
|
||||||
|
if IRecordModifiedEvent.providedBy(event):
|
||||||
|
# Discussion control panel setting changed
|
||||||
|
if event.record.fieldName == 'moderation_enabled':
|
||||||
|
# Moderation enabled has changed
|
||||||
|
if event.record.value == True:
|
||||||
|
# Enable moderation workflow
|
||||||
|
wftool.setChainForPortalTypes(('Discussion Item',),
|
||||||
|
'comment_review_workflow')
|
||||||
|
else:
|
||||||
|
# Disable moderation workflow
|
||||||
|
wftool.setChainForPortalTypes(('Discussion Item',),
|
||||||
|
'one_state_workflow')
|
||||||
|
|
||||||
|
from plone.app.controlpanel.interfaces import IConfigurationChangedEvent
|
||||||
|
if IConfigurationChangedEvent.providedBy(event):
|
||||||
|
# Types control panel setting changed
|
||||||
|
# XXX: Todo!!!
|
||||||
|
pass
|
||||||
|
|
||||||
|
@ -44,6 +44,22 @@ class IDiscussionSettings(Interface):
|
|||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
moderation_enabled = schema.Bool(
|
||||||
|
title=_(u"label_moderation_enabled",
|
||||||
|
default="Enable comment moderation"),
|
||||||
|
description=_(u"help_moderation_enabled",
|
||||||
|
default=u"If selected, comments will enter a 'Pending' state "
|
||||||
|
"in which they are invisible to the public. A user "
|
||||||
|
"with the 'Review comments' permission ('Reviewer' or "
|
||||||
|
"'Manager') can approve comments to make them visible "
|
||||||
|
"to the public. If you want to enable a custom "
|
||||||
|
"comment workflow, you have to go to the types "
|
||||||
|
"control panel."),
|
||||||
|
required=False,
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
text_transform = schema.Choice(
|
text_transform = schema.Choice(
|
||||||
title=_(u"label_text_transform",
|
title=_(u"label_text_transform",
|
||||||
default="Comment text transform"),
|
default="Comment text transform"),
|
||||||
|
@ -88,4 +88,14 @@
|
|||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
||||||
|
<subscriber
|
||||||
|
for="plone.app.controlpanel.interfaces.IConfigurationChangedEvent"
|
||||||
|
handler=".browser.controlpanel.notify_configuration_changed"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<subscriber
|
||||||
|
for="plone.registry.interfaces.IRecordModifiedEvent"
|
||||||
|
handler=".browser.controlpanel.notify_configuration_changed"
|
||||||
|
/>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
@ -90,5 +90,21 @@ class RegistryTest(PloneTestCase):
|
|||||||
# self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
# self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
||||||
# 'IDiscussionSettings.user_notification_enabled'], False)
|
# 'IDiscussionSettings.user_notification_enabled'], False)
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigurationChangedSubscriberTest(PloneTestCase):
|
||||||
|
|
||||||
|
layer = DiscussionLayer
|
||||||
|
|
||||||
|
def afterSetUp(self):
|
||||||
|
self.loginAsPortalOwner()
|
||||||
|
# Set up the registry
|
||||||
|
self.registry = Registry()
|
||||||
|
self.registry.registerInterface(IDiscussionSettings)
|
||||||
|
|
||||||
|
def todo(self):
|
||||||
|
# XXX: Todo!!!
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||||
|
Loading…
Reference in New Issue
Block a user