Return-Path: X-Original-To: apmail-allura-commits-archive@www.apache.org Delivered-To: apmail-allura-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3C89C1082E for ; Tue, 8 Dec 2015 11:32:45 +0000 (UTC) Received: (qmail 5021 invoked by uid 500); 8 Dec 2015 11:32:35 -0000 Delivered-To: apmail-allura-commits-archive@allura.apache.org Received: (qmail 4966 invoked by uid 500); 8 Dec 2015 11:32:35 -0000 Mailing-List: contact commits-help@allura.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@allura.apache.org Delivered-To: mailing list commits@allura.apache.org Received: (qmail 4813 invoked by uid 99); 8 Dec 2015 11:32:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Dec 2015 11:32:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 85DA4E09E6; Tue, 8 Dec 2015 11:32:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jetmind@apache.org To: commits@allura.apache.org Date: Tue, 08 Dec 2015 11:32:42 -0000 Message-Id: <5cbd3abe88944c0998ecb4a6a2ae4336@git.apache.org> In-Reply-To: <3cfcc95408b842d2bb28979680fe8702@git.apache.org> References: <3cfcc95408b842d2bb28979680fe8702@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [8/9] allura git commit: [#8023] ticket:868 change logic in checking rights, fix tests [#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/2369f73b Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2369f73b Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2369f73b Branch: refs/heads/ib/8023a Commit: 2369f73b002a654ecbd58639212062f5fb80e261 Parents: 23a5ccb Author: Denis Kotov Authored: Mon Dec 7 19:21:34 2015 +0200 Committer: Denis Kotov Committed: Mon Dec 7 19:21:34 2015 +0200 ---------------------------------------------------------------------- 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/2369f73b/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/2369f73b/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)