allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [07/12] allura git commit: [#8023] ticket:868 change logic in checking rights, fix tests
Date Tue, 15 Dec 2015 15:49:00 GMT
[#8023] ticket:868 change logic in checking rights, fix tests


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

Branch: refs/heads/master
Commit: 6aa9993d7b854542dc93815c937c057e22793ce6
Parents: 634ca4b
Author: Denis Kotov <deniskkotov@gmail.com>
Authored: Mon Dec 7 19:21:34 2015 +0200
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Tue Dec 15 10:05:56 2015 -0500

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py        | 12 +++++-------
 Allura/allura/tests/test_plugin.py | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6aa9993d/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 43cc98f..7768e2b 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -1324,14 +1324,12 @@ class ThemeProvider(object):
                 only_user_project = projects.count() == 1 and projects.first().is_user_project
                 if projects.count() == 0 or only_user_project:
                     return None
-        tool_matching = False
-        url_matching = False
-        if note.page_tool_type is None or c.app is not None and c.app.config.tool_name.lower()
== note.page_tool_type.lower():
-            tool_matching = True
-        if note.page_regex is None or re.search(note.page_regex, request.url):
-            tool_matching = True
-        if not tool_matching and not url_matching:
+
+        if note.page_regex is not None and re.search(note.page_regex, request.url) is None:
+            return None
+        if note.page_tool_type is not None and (c.app is None or c.app.config.tool_name.lower()
!= note.page_tool_type.lower()):
             return None
+
         cookie = request.cookies.get('site-notification', '').split('-')
         if len(cookie) == 3 and cookie[0] == str(note._id):
             views = asint(cookie[1]) + 1

http://git-wip-us.apache.org/repos/asf/allura/blob/6aa9993d/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index f1693be..2e7baae 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -438,8 +438,8 @@ class TestThemeProvider(object):
         search.return_value = True
         assert_is(ThemeProvider().get_site_notification(), note)
 
-        search.return_value = False
-        assert_is(ThemeProvider().get_site_notification(), note)
+        search.return_value = None
+        assert_is(ThemeProvider().get_site_notification(), None)
 
     @patch('allura.model.notification.SiteNotification')
     def test_get_site_notification_with_page_tool_type(self, SiteNotification):
@@ -453,10 +453,10 @@ class TestThemeProvider(object):
         assert_is(ThemeProvider().get_site_notification(), note)
 
         c.app.config.tool_name.lower.return_value = 'test2'
-        assert_is(ThemeProvider().get_site_notification(), note)
+        assert_is(ThemeProvider().get_site_notification(), None)
 
         c.app = None
-        assert_is(ThemeProvider().get_site_notification(), note)
+        assert_is(ThemeProvider().get_site_notification(), None)
 
     @patch('re.search')
     @patch('allura.model.notification.SiteNotification')
@@ -467,24 +467,24 @@ class TestThemeProvider(object):
         c.app = Mock()
         note.page_tool_type.lower.return_value = 'test1'
 
-        search.return_value = False
+        search.return_value = None
         c.app.config.tool_name.lower.return_value = 'test2'
         assert_is(ThemeProvider().get_site_notification(), None)
 
         search.return_value = True
-        assert_is(ThemeProvider().get_site_notification(), note)
+        assert_is(ThemeProvider().get_site_notification(), None)
 
-        search.return_value = False
+        search.return_value = None
         c.app.config.tool_name.lower.return_value = 'test1'
-        assert_is(ThemeProvider().get_site_notification(), note)
+        assert_is(ThemeProvider().get_site_notification(), None)
 
         search.return_value = True
         assert_is(ThemeProvider().get_site_notification(), note)
 
         c.app = None
-        assert_is(ThemeProvider().get_site_notification(), note)
+        assert_is(ThemeProvider().get_site_notification(), None)
 
-        search.return_value = False
+        search.return_value = None
         assert_is(ThemeProvider().get_site_notification(), None)
 
 


Mime
View raw message