From 31ecf3812982022e658b26a3bef0739d542e9a52 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Fri, 22 Apr 2011 13:34:50 +0000 Subject: [PATCH] Provide the comment body text in the email notification. svn path=/plone.app.discussion/trunk/; revision=49032 --- CHANGES.txt | 3 +++ plone/app/discussion/comment.py | 15 ++++++++++----- plone/app/discussion/tests/test_notifications.py | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ed3180c..2c06599 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,9 @@ Changelog 2.0.1 (2011-04-22) ------------------ +- Provide the comment body text in the email notification. + [timo] + - Fix comment link in email notification. This fixes http://dev.plone.org/plone/ticket/11413. [timo] diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index 0993b00..3b7727a 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -52,7 +52,10 @@ COMMENT_TITLE = _(u"comment_title", MAIL_NOTIFICATION_MESSAGE = _(u"mail_notification_message", default=u"A comment on '${title}' " - "has been posted here: ${link}") + "has been posted here: ${link}\n\n" + "---\n\n" + "${text}" + "---\n") logger = logging.getLogger("plone.app.discussion") @@ -244,17 +247,18 @@ def notify_user(obj, event): if (obj != comment and comment.user_notification and comment.author_email): emails.add(comment.author_email) - + if not emails: return - + subject = translate(_(u"A comment has been posted."), context=obj.REQUEST) message = translate(Message( MAIL_NOTIFICATION_MESSAGE, mapping={'title': safe_unicode(content_object.title), 'link': content_object.absolute_url() + - '/view#' + obj.id}), + '/view#' + obj.id, + 'text': obj.text}), context=obj.REQUEST) for email in emails: # Send email @@ -315,7 +319,8 @@ def notify_moderator(obj, event): message = translate(Message(MAIL_NOTIFICATION_MESSAGE, mapping={'title': safe_unicode(content_object.title), 'link': content_object.absolute_url() + - '/view#' + obj.id}), + '/view#' + obj.id, + 'text': obj.text}), context=obj.REQUEST) # Send email diff --git a/plone/app/discussion/tests/test_notifications.py b/plone/app/discussion/tests/test_notifications.py index 23902b7..f0d401d 100644 --- a/plone/app/discussion/tests/test_notifications.py +++ b/plone/app/discussion/tests/test_notifications.py @@ -87,6 +87,7 @@ class TestUserNotificationUnit(unittest.TestCase): "http://nohost/plone/d=\noc1/view#%s" % comment_id in msg) + self.assertTrue('Comment text' in msg) def test_do_not_notify_user_when_notification_is_disabled(self): registry = queryUtility(IRegistry) @@ -220,6 +221,7 @@ class TestModeratorNotificationUnit(unittest.TestCase): "http://nohost/plone/d=\noc1/view#%s" % comment_id in msg) + self.assertTrue('Comment text' in msg) def test_notify_moderator_specific_address(self): # A moderator email address can be specified in the control panel.