incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/2] git commit: [#6883] ticket:497 add template with footer for message and fixed test
Date Wed, 27 Nov 2013 16:52:23 GMT
[#6883] ticket:497 add template with footer for message and fixed test


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e8dbd2e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e8dbd2e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e8dbd2e5

Branch: refs/heads/master
Commit: e8dbd2e52e53dea2bb9efdd8ac8ea7a5088951b4
Parents: 3b35ab4
Author: Yaroslav Sokolovsky <yaroslav.sokolovsky@gmail.com>
Authored: Thu Nov 21 16:56:40 2013 +0200
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Nov 27 16:48:37 2013 +0000

----------------------------------------------------------------------
 .../ext/user_profile/templates/message.html     | 22 ++++++++++++++++++++
 Allura/allura/model/auth.py                     | 10 ++++++++-
 .../tests/functional/test_user_profile.py       |  4 ++--
 3 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8dbd2e5/Allura/allura/ext/user_profile/templates/message.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/templates/message.html b/Allura/allura/ext/user_profile/templates/message.html
new file mode 100644
index 0000000..9e13b3c
--- /dev/null
+++ b/Allura/allura/ext/user_profile/templates/message.html
@@ -0,0 +1,22 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{{message_text}}
+--
+This message was sent to you via the {{site_name}} web mail form.  You may reply to this
message directly, or at {{base_url}}/u/{{username}}/profile/send_message
+

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8dbd2e5/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index e3587cf..432898b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -31,6 +31,7 @@ from datetime import timedelta, datetime, time
 
 import iso8601
 import pymongo
+from tg import config
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
 
@@ -384,13 +385,20 @@ class User(MappedClass, ActivityNode, ActivityObject):
         """Send a user message (email) to ``user``.
 
         """
+        tmpl = g.jinja2_env.get_template('allura:ext/user_profile/templates/message.html')
+        tmpl_context = {
+            'message_text': message,
+            'site_name': config['site_name'],
+            'base_url': config['base_url'],
+            'username': c.user.username,
+        }
         allura.tasks.mail_tasks.sendsimplemail.post(
             toaddr=user.get_pref('email_address'),
             fromaddr=self.get_pref('email_address'),
             reply_to=self.get_pref('email_address'),
             message_id=h.gen_message_id(),
             subject=subject,
-            text=message,
+            text=tmpl.render(tmpl_context),
             cc=cc)
         self.sent_user_message_times.append(datetime.utcnow())
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e8dbd2e5/Allura/allura/tests/functional/test_user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 7b17d28..6e4618d 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -80,7 +80,7 @@ class TestUserProfile(TestController):
 
         sendsimplemail.post.assert_called_once_with(
             cc=User.by_username('test-admin').get_pref('email_address'),
-            text=u'test message',
+            text=u'test message\n--\nThis message was sent to you via the Allura web mail
form.  You may reply to this message directly, or at http://localhost/u/test-admin/profile/send_message\n',
             toaddr=User.by_username('test-user').get_pref('email_address'),
             fromaddr=User.by_username('test-admin').get_pref('email_address'),
             reply_to=User.by_username('test-admin').get_pref('email_address'),
@@ -93,7 +93,7 @@ class TestUserProfile(TestController):
 
         sendsimplemail.post.assert_called_once_with(
             cc=None,
-            text=u'test message',
+            text=u'test message\n--\nThis message was sent to you via the Allura web mail
form.  You may reply to this message directly, or at http://localhost/u/test-admin/profile/send_message\n',
             toaddr=User.by_username('test-user').get_pref('email_address'),
             fromaddr=User.by_username('test-admin').get_pref('email_address'),
             reply_to=User.by_username('test-admin').get_pref('email_address'),


Mime
View raw message