This is an automated email from the ASF dual-hosted git repository. dill0wn pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 3b1ae04b80f2f01b3263238999aadd9e64f361af Author: Guillermo Cruz <[email protected]> AuthorDate: Tue Nov 16 15:33:58 2021 -0700 reverted FROM: field changes and set message_reply_real_address to false if checkbox is unchecked --- .../ext/user_profile/templates/send_message_form.html | 2 +- Allura/allura/ext/user_profile/user_main.py | 4 +++- Allura/allura/model/auth.py | 1 + Allura/allura/tasks/mail_tasks.py | 3 +-- Allura/allura/tests/functional/test_user_profile.py | 4 ++-- Allura/allura/tests/test_tasks.py | 16 ++++++++-------- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Allura/allura/ext/user_profile/templates/send_message_form.html b/Allura/allura/ext/user_profile/templates/send_message_form.html index df31796..26caa8f 100644 --- a/Allura/allura/ext/user_profile/templates/send_message_form.html +++ b/Allura/allura/ext/user_profile/templates/send_message_form.html @@ -31,7 +31,7 @@ <b>To:</b> <a href="{{user.url()}}">{{user.display_name|default(user.username)}}</a> </div> <div class="grid-19"> - <b>From:</b> {{c.user.email_address_header()}} + <b>From:</b> {{c.user.display_name}} </div> <div class="grid-19"> </div> <form method="{{method}}" action="{{action}}"> diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py index b7ca32b..22b4200 100644 --- a/Allura/allura/ext/user_profile/user_main.py +++ b/Allura/allura/ext/user_profile/user_main.py @@ -209,6 +209,8 @@ class UserProfileController(BaseController, FeedController): if c.user.can_send_user_message(): if reply_to_real_address: c.user.set_pref('message_reply_real_address', True) + else: + c.user.set_pref('message_reply_real_address', False) c.user.send_user_message( c.project.user_project_of, subject, message, cc, reply_to_real_address, c.user.preferences.email_address) flash("Message sent.") @@ -217,7 +219,7 @@ class UserProfileController(BaseController, FeedController): g.user_message_max_messages, g.user_message_time_interval), 'error') return redirect(c.project.user_project_of.url()) - + @without_trailing_slash @expose('jinja:allura.ext.user_profile:templates/user_card.html') def user_card(self): diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py index 1aa71ea..c656065 100644 --- a/Allura/allura/model/auth.py +++ b/Allura/allura/model/auth.py @@ -819,6 +819,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable): h = header.Header() h.append('"%s"%s' % (self.get_pref('display_name'), ' ' if six.PY2 else '')) # py2 needs explicit space for unicode/text_type cast of Header + h.append('<%s>' % self.get_pref('email_address')) return h def update_notifications(self): diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py index 0df7cc0..c6da880 100644 --- a/Allura/allura/tasks/mail_tasks.py +++ b/Allura/allura/tasks/mail_tasks.py @@ -176,8 +176,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject, except Exception: log.exception('Error looking up user with ID: %r' % addr) continue - # retrieve active email address - addr = user.preferences.email_address + addr = user.email_address_header() if not addr and user.email_addresses: addr = user.email_addresses[0] log.warning( diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py index 0db7d57..ecaa6f5 100644 --- a/Allura/allura/tests/functional/test_user_profile.py +++ b/Allura/allura/tests/functional/test_user_profile.py @@ -115,7 +115,7 @@ class TestUserProfile(TestController): response = self.app.get( '/u/test-user/profile/send_message', status=200) assert 'you currently have user messages disabled' not in response - response.mustcontain('<b>From:</b> "Test Admin"') + response.mustcontain('<b>From:</b> Test Admin') self.app.post('/u/test-user/profile/send_user_message', params={'subject': 'test subject', @@ -163,7 +163,7 @@ class TestUserProfile(TestController): response = self.app.get( '/u/test-user/profile/send_message', status=200) assert 'you currently have user messages disabled' not in response - response.mustcontain('<b>From:</b> "Test Admin"') + response.mustcontain('<b>From:</b> Test Admin') self.app.post('/u/test-user/profile/send_user_message', params={'subject': 'test subject', 'message': 'test message', diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py index ec664e9..7c73399 100644 --- a/Allura/allura/tests/test_tasks.py +++ b/Allura/allura/tests/test_tasks.py @@ -34,7 +34,7 @@ import mock from tg import tmpl_context as c, app_globals as g from datadiff.tools import assert_equal -from alluratest.tools import assert_in, assert_less +from nose.tools import assert_in, assert_less from ming.orm import FieldProperty, Mapper from ming.orm import ThreadLocalORMSession from testfixtures import LogCapture @@ -271,7 +271,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(rcpts, [c.user.get_pref('email_address')]) assert_in('Reply-To: %s' % g.noreply, body) - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) assert_in('Subject: Test subject', body) # plain assert_in('This is a test', body) @@ -355,7 +355,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(_client.sendmail.call_count, 1) return_path, rcpts, body = _client.sendmail.call_args[0] body = body.split('\n') - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) c.user.disabled = True ThreadLocalORMSession.flush_all() @@ -385,7 +385,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(_client.sendmail.call_count, 1) return_path, rcpts, body = _client.sendmail.call_args[0] body = body.split('\n') - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) assert_in('Sender: [email protected]', body) assert_in('To: [email protected]', body) @@ -401,7 +401,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(_client.sendmail.call_count, 1) return_path, rcpts, body = _client.sendmail.call_args[0] body = body.split('\n') - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) assert_in('Sender: [email protected]', body) assert_in('To: [email protected]', body) @@ -419,7 +419,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(_client.sendmail.call_count, 1) return_path, rcpts, body = _client.sendmail.call_args[0] body = body.split('\n') - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) assert_in('References: <a> <b> <c>', body) _client.reset_mock() @@ -434,7 +434,7 @@ class TestMailTasks(unittest.TestCase): assert_equal(_client.sendmail.call_count, 1) return_path, rcpts, body = _client.sendmail.call_args[0] body = body.split('\n') - assert_in('From: "Test Admin"', body) + assert_in('From: "Test Admin" <[email protected]>', body) assert_in('References: <ref>', body) def test_cc(self): @@ -465,7 +465,7 @@ class TestMailTasks(unittest.TestCase): 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"', body) + assert_in('From: "Test Admin" <[email protected]>', body) def test_send_email_long_lines_use_quoted_printable(self): with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
