add moderator email setting
svn path=/plone.app.discussion/branches/1.x/; revision=48523
This commit is contained in:
parent
6413096336
commit
9aea1915c1
@ -269,9 +269,12 @@ def notify_user(obj, event):
|
|||||||
def notify_moderator(obj, event):
|
def notify_moderator(obj, event):
|
||||||
"""Tell the moderator when a comment needs attention.
|
"""Tell the moderator when a comment needs attention.
|
||||||
|
|
||||||
This method sends an email to the site admin (mail control panel setting)
|
This method sends an email to the moderator if comment moderation is
|
||||||
if comment moderation is enabled and a new comment has been added that
|
enabled and a new comment has been added that needs to be approved.
|
||||||
needs to be approved.
|
|
||||||
|
Configure the moderator e-mail address in the discussion control panel.
|
||||||
|
If no moderator is configured but moderator notifications are turned on,
|
||||||
|
the site admin email (from the mail control panel) will be used.
|
||||||
|
|
||||||
This requires the moderator_notification to be enabled in the discussion
|
This requires the moderator_notification to be enabled in the discussion
|
||||||
control panel and the comment_review_workflow enabled for the comment
|
control panel and the comment_review_workflow enabled for the comment
|
||||||
@ -289,7 +292,11 @@ def notify_moderator(obj, event):
|
|||||||
portal_url = getToolByName(obj, 'portal_url')
|
portal_url = getToolByName(obj, 'portal_url')
|
||||||
portal = portal_url.getPortalObject()
|
portal = portal_url.getPortalObject()
|
||||||
sender = portal.getProperty('email_from_address')
|
sender = portal.getProperty('email_from_address')
|
||||||
mto = portal.getProperty('email_from_address')
|
|
||||||
|
if settings.moderator_email:
|
||||||
|
mto = settings.moderator_email
|
||||||
|
else:
|
||||||
|
mto = sender
|
||||||
|
|
||||||
# Check if a sender address is available
|
# Check if a sender address is available
|
||||||
if not sender:
|
if not sender:
|
||||||
|
@ -113,6 +113,16 @@ class IDiscussionSettings(Interface):
|
|||||||
required=False,
|
required=False,
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
moderator_email = schema.ASCIILine(
|
||||||
|
title = _(u'label_moderator_email', default=u'Moderator Email Address'),
|
||||||
|
description = _(u'help_moderator_email',
|
||||||
|
default=u"Address to which moderator notifications "
|
||||||
|
u"will be sent. If not specified, the Site "
|
||||||
|
u"'From' Address from the mail control panel "
|
||||||
|
u"will be used."),
|
||||||
|
required = False,
|
||||||
|
)
|
||||||
|
|
||||||
user_notification_enabled = schema.Bool(
|
user_notification_enabled = schema.Bool(
|
||||||
title=_(u"label_user_notification_enabled",
|
title=_(u"label_user_notification_enabled",
|
||||||
|
@ -16,7 +16,6 @@ from Products.CMFPlone.tests.utils import MockMailHost
|
|||||||
from plone.registry.interfaces import IRegistry
|
from plone.registry.interfaces import IRegistry
|
||||||
|
|
||||||
from plone.app.discussion.interfaces import IConversation
|
from plone.app.discussion.interfaces import IConversation
|
||||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
|
||||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
|
|
||||||
# Enable user notification setting
|
# Enable user notification setting
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
settings = registry.forInterface(IDiscussionSettings)
|
|
||||||
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
|
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
|
||||||
'.user_notification_enabled'] = True
|
'.user_notification_enabled'] = True
|
||||||
|
|
||||||
@ -89,7 +87,6 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
def test_do_not_notify_user_when_notification_is_disabled(self):
|
def test_do_not_notify_user_when_notification_is_disabled(self):
|
||||||
# Disable user notification and make sure no email is send to the user.
|
# Disable user notification and make sure no email is send to the user.
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
settings = registry.forInterface(IDiscussionSettings)
|
|
||||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||||
'user_notification_enabled'] = False
|
'user_notification_enabled'] = False
|
||||||
|
|
||||||
@ -241,6 +238,23 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
|||||||
#'...Another t=C3=A4st message...You are receiving this mail because
|
#'...Another t=C3=A4st message...You are receiving this mail because
|
||||||
# T=C3=A4st user\ntest@plone.test...is sending feedback about the site
|
# T=C3=A4st user\ntest@plone.test...is sending feedback about the site
|
||||||
# you administer at...
|
# you administer at...
|
||||||
|
|
||||||
|
def test_notify_moderator_specific_address(self):
|
||||||
|
# A moderator email address can be specified in the control panel.
|
||||||
|
registry = queryUtility(IRegistry)
|
||||||
|
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
|
||||||
|
'.moderator_email'] = 'test@example.com'
|
||||||
|
|
||||||
|
comment = createObject('plone.Comment')
|
||||||
|
comment.text = 'Comment text'
|
||||||
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
|
self.assertEquals(len(self.mailhost.messages), 1)
|
||||||
|
msg = self.mailhost.messages[0]
|
||||||
|
if not isinstance(msg, str):
|
||||||
|
self.failUnless('test@example.com' in msg.mto)
|
||||||
|
else:
|
||||||
|
self.failUnless('To: test@example.com' in msg)
|
||||||
|
|
||||||
def test_do_not_notify_moderator_when_no_sender_is_available(self):
|
def test_do_not_notify_moderator_when_no_sender_is_available(self):
|
||||||
# Set sender mail address to nonw and make sure no email is send to the
|
# Set sender mail address to nonw and make sure no email is send to the
|
||||||
|
Loading…
Reference in New Issue
Block a user