You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/09/15 20:47:23 UTC
[1/2] git commit: [#7677] update mail tasks to handle actual ObjectId
in addr params
Repository: allura
Updated Branches:
refs/heads/db/7677 [created] 2be2ce626
[#7677] update mail tasks to handle actual ObjectId in addr params
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/64a05dca
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/64a05dca
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/64a05dca
Branch: refs/heads/db/7677
Commit: 64a05dcaef2572a238b452ac15712b131cac0994
Parents: 505174a
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Sep 15 18:41:44 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 15 18:41:44 2014 +0000
----------------------------------------------------------------------
Allura/allura/tasks/mail_tasks.py | 15 +++++++++++----
Allura/allura/tests/test_tasks.py | 14 ++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/64a05dca/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 4fce0d7..110160d 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -88,6 +88,10 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
'''
Send an email to the specified list of destinations with respect to the preferred email format specified by user.
It is best for broadcast messages.
+
+ :param fromaddr: ObjectId or str(ObjectId) of user, or email address str
+ :param toaddr: ObjectId or str(ObjectId) of user, or email address str
+
'''
from allura import model as M
addrs_plain = []
@@ -95,7 +99,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
addrs_multi = []
if fromaddr is None:
fromaddr = g.noreply
- elif '@' not in fromaddr:
+ elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
log.warning('Looking up user with fromaddr: %s', fromaddr)
user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
if not user:
@@ -164,11 +168,15 @@ def sendsimplemail(
'''
Send a single mail to the specified address.
It is best for single user notifications.
+
+ :param fromaddr: ObjectId or str(ObjectId) of user, or email address str
+ :param toaddr: ObjectId or str(ObjectId) of user, or email address str
+
'''
from allura import model as M
if fromaddr is None:
fromaddr = g.noreply
- elif '@' not in fromaddr:
+ elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
log.warning('Looking up user with fromaddr: %s', fromaddr)
user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
if not user:
@@ -177,8 +185,7 @@ def sendsimplemail(
else:
fromaddr = user.email_address_header()
-
- if '@' not in toaddr:
+ if not isinstance(toaddr, basestring) or '@' not in toaddr:
log.warning('Looking up user with toaddr: %s', toaddr)
user = M.User.query.get(_id=ObjectId(toaddr), disabled=False)
if not user:
http://git-wip-us.apache.org/repos/asf/allura/blob/64a05dca/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 5dd70b6..13d5c17 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -388,6 +388,20 @@ class TestMailTasks(unittest.TestCase):
assert_in('CC: someone@example.com', body)
assert_in('someone@example.com', rcpts)
+ def test_fromaddr_objectid_not_str(self):
+ c.user = M.User.by_username('test-admin')
+ with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
+ mail_tasks.sendsimplemail(
+ fromaddr=c.user._id,
+ toaddr='test@mail.com',
+ text=u'This is a test',
+ reply_to=g.noreply,
+ subject=u'Test subject',
+ message_id=h.gen_message_id())
+ assert_equal(_client.sendmail.call_count, 1)
+ return_path, rcpts, body = _client.sendmail.call_args[0]
+ assert_in('From: "Test Admin" <te...@users.localhost>', body)
+
@td.with_wiki
def test_receive_email_ok(self):
c.user = M.User.by_username('test-admin')
[2/2] git commit: [#7677] change verification link to be protocol
relative so referrer is always there (https/http switch may drop it) and
after flash you go back to the right page
Posted by br...@apache.org.
[#7677] change verification link to be protocol relative so referrer is always there (https/http switch may drop it) and after flash you go back to the right page
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2be2ce62
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2be2ce62
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2be2ce62
Branch: refs/heads/db/7677
Commit: 2be2ce626fc6353b56a96f19370837569d83cce0
Parents: 64a05dc
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Sep 15 18:45:39 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Sep 15 18:45:39 2014 +0000
----------------------------------------------------------------------
Allura/allura/templates/user_prefs.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/2be2ce62/Allura/allura/templates/user_prefs.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/user_prefs.html b/Allura/allura/templates/user_prefs.html
index fec5dcd..913bf8b 100644
--- a/Allura/allura/templates/user_prefs.html
+++ b/Allura/allura/templates/user_prefs.html
@@ -93,7 +93,7 @@
{% if obj.confirmed %}
yes
{% else %}
- no (<a href="{{g.url('/auth/send_verification_link', a=a)}}">verify</a>)
+ no (<a href="/auth/send_verification_link?a={{a}}">verify</a>)
{% endif %}
</td>
{% else %}