allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: [#8244] Warn user if attempting to send messages when messaging is disabled
Date Fri, 12 Oct 2018 17:45:29 GMT
Repository: allura
Updated Branches:
  refs/heads/kt/8244 [created] 8ac4bb0b1


[#8244] Warn user if attempting to send messages when messaging is disabled


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

Branch: refs/heads/kt/8244
Commit: 8ac4bb0b1ee63620a0ad732e95186b29465b303f
Parents: cd8321c
Author: Kenton Taylor <ktaylor@slashdotmedia.com>
Authored: Fri Oct 12 17:45:17 2018 +0000
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Fri Oct 12 17:45:17 2018 +0000

----------------------------------------------------------------------
 .../user_profile/templates/send_message_form.html    | 11 ++++++++++-
 Allura/allura/tests/functional/test_user_profile.py  | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8ac4bb0b/Allura/allura/ext/user_profile/templates/send_message_form.html
----------------------------------------------------------------------
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 1a083ac..06e4330 100644
--- a/Allura/allura/ext/user_profile/templates/send_message_form.html
+++ b/Allura/allura/ext/user_profile/templates/send_message_form.html
@@ -17,10 +17,19 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+
 <div class="editbox">
+    {% if  c.user.get_pref('disable_user_messages') %}
+    <div class="grid-19 notice">
+        Note: you currently have user messages disabled; you can send this user a note, but
you'll be unable to receive any reply without first
+        <a href="/auth/preferences">changing your settings</a>, or providing
your email address in the body of the note.
+    </div>
+    {% endif %}
+
     <div class="grid-19">
         <b>To:</b> <a href="{{user.url()}}">{{user.display_name|default(user.username)}}</a>
-        </div>
+    </div>
     <div class="grid-19">
         <b>From:</b> {{c.user.email_address_header()}}
     </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/8ac4bb0b/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 2707260..04d6458 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -95,7 +95,9 @@ class TestUserProfile(TestController):
         test_user.set_pref('email_address', 'test-user@example.com')
         response = self.app.get(
             '/u/test-user/profile/send_message', status=200)
+        assert 'you currently have user messages disabled' not in response
         assert '<b>From:</b> &#34;Test Admin&#34; &lt;test-admin@users.localhost&gt;'
in response
+
         self.app.post('/u/test-user/profile/send_user_message',
                       params={'subject': 'test subject',
                               'message': 'test message',
@@ -168,6 +170,19 @@ class TestUserProfile(TestController):
         assert 'This user has disabled direct email messages' in self.webflash(
             r)
 
+    @td.with_user_project('test-admin')
+    @td.with_user_project('test-user')
+    def test_user_messages_sender_disabled(self):
+        admin_user = User.by_username('test-admin')
+        admin_user.set_pref('email_address', 'admin@example.com')
+        admin_user.set_pref('disable_user_messages', True)
+
+        test_user = User.by_username('test-user')
+        test_user.set_pref('email_address', 'user@example.com')
+
+        r = self.app.get('/u/test-user/profile/send_message', status=200)
+        assert 'you currently have user messages disabled' in r
+
     @td.with_user_project('test-user')
     def test_profile_sections(self):
         project = Project.query.get(shortname='u/test-user')


Mime
View raw message