This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8556-breaking-removal
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 54573223031f45e2df820bc90dda57fe92721713
Author: Dave Brondsema <dbronds...@slashdotmedia.com>
AuthorDate: Wed Apr 3 13:43:48 2024 -0400

    [#8556] simplify more calls
---
 Allura/allura/app.py                                      | 2 +-
 Allura/allura/controllers/auth.py                         | 6 +++---
 Allura/allura/ext/admin/admin_main.py                     | 2 +-
 Allura/allura/tests/model/test_artifact.py                | 6 +++---
 Allura/allura/tests/test_plugin.py                        | 2 +-
 ForgeBlog/forgeblog/tests/test_roles.py                   | 8 ++++++--
 ForgeDiscussion/forgediscussion/tests/test_forum_roles.py | 8 ++++++--
 ForgeFeedback/forgefeedback/tests/test_feedback_roles.py  | 8 ++++++--
 ForgeFiles/forgefiles/tests/test_files_roles.py           | 8 ++++++--
 ForgeShortUrl/forgeshorturl/main.py                       | 2 +-
 ForgeTracker/forgetracker/tests/test_tracker_roles.py     | 8 ++++++--
 ForgeTracker/forgetracker/tracker_main.py                 | 6 +++---
 ForgeWiki/forgewiki/tests/test_wiki_roles.py              | 8 ++++++--
 ForgeWiki/forgewiki/wiki_main.py                          | 2 +-
 14 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 518269622..55cb7d299 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -495,7 +495,7 @@ class Application(ActivityObject):
         :rtype: bool
 
         """
-        return has_access(self, 'read')(user=user)
+        return has_access(self, 'read', user)
 
     def subscribe_admins(self):
         """Subscribe all project Admins (for this Application's project) to the
diff --git a/Allura/allura/controllers/auth.py 
b/Allura/allura/controllers/auth.py
index d74f48445..fab1757e8 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -513,9 +513,9 @@ class AuthController(BaseController):
             log.info("Can't find repo at %s on repo_path %s",
                      rest[0], repo_path)
             return disallow
-        return dict(allow_read=has_access(c.app, 'read')(user=user),
-                    allow_write=has_access(c.app, 'write')(user=user),
-                    allow_create=has_access(c.app, 'create')(user=user))
+        return dict(allow_read=bool(has_access(c.app, 'read', user)),
+                    allow_write=bool(has_access(c.app, 'write', user)),
+                    allow_create=bool(has_access(c.app, 'create', user)))
 
     @expose('jinja:allura:templates/pwd_expired.html')
     @without_trailing_slash
diff --git a/Allura/allura/ext/admin/admin_main.py 
b/Allura/allura/ext/admin/admin_main.py
index 0904c0ce8..6feecd038 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -97,7 +97,7 @@ class AdminApp(Application):
 
     def is_visible_to(self, user):
         '''Whether the user can view the app.'''
-        return has_access(c.project, 'create')(user=user)
+        return has_access(c.project, 'create', user)
 
     @staticmethod
     def installable_tools_for(project):
diff --git a/Allura/allura/tests/model/test_artifact.py 
b/Allura/allura/tests/model/test_artifact.py
index 9eb2c8b4e..d63a2041e 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -85,13 +85,13 @@ class TestArtifact:
         pr = M.ProjectRole.by_user(u, upsert=True)
         ThreadLocalODMSession.flush_all()
         REGISTRY.register(allura.credentials, 
allura.lib.security.Credentials())
-        assert not security.has_access(pg, 'delete')(user=u)
+        assert not security.has_access(pg, 'delete', u)
         pg.acl.append(M.ACE.allow(pr._id, 'delete'))
         ThreadLocalODMSession.flush_all()
-        assert security.has_access(pg, 'delete')(user=u)
+        assert security.has_access(pg, 'delete', u)
         pg.acl.pop()
         ThreadLocalODMSession.flush_all()
-        assert not security.has_access(pg, 'delete')(user=u)
+        assert not security.has_access(pg, 'delete', u)
 
     def test_artifact_index(self):
         pg = WM.Page(title='TestPage1')
diff --git a/Allura/allura/tests/test_plugin.py 
b/Allura/allura/tests/test_plugin.py
index 964502cf2..c57e9e4a4 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -50,7 +50,7 @@ class TestProjectRegistrationProvider:
 
     @patch('allura.lib.security.has_access')
     def test_validate_project_15char_user(self, has_access):
-        has_access.return_value = TruthyCallable(lambda: True)
+        has_access.return_value = True
         nbhd = M.Neighborhood()
         self.provider.validate_project(
             neighborhood=nbhd,
diff --git a/ForgeBlog/forgeblog/tests/test_roles.py 
b/ForgeBlog/forgeblog/tests/test_roles.py
index 18403dce9..e52ffcdb9 100644
--- a/ForgeBlog/forgeblog/tests/test_roles.py
+++ b/ForgeBlog/forgeblog/tests/test_roles.py
@@ -37,8 +37,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('configure') == (True, False, False)
     assert check_access('read') == (True, True, True)
     assert check_access('write') == (True, False, False)
diff --git a/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py 
b/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
index f05c6d993..0651134a0 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
@@ -35,8 +35,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('configure') == (True, False, False)
     assert check_access('read') == (True, True, True)
     assert check_access('unmoderated_post') == (True, True, False)
diff --git a/ForgeFeedback/forgefeedback/tests/test_feedback_roles.py 
b/ForgeFeedback/forgefeedback/tests/test_feedback_roles.py
index 33faa8290..1751e978d 100644
--- a/ForgeFeedback/forgefeedback/tests/test_feedback_roles.py
+++ b/ForgeFeedback/forgefeedback/tests/test_feedback_roles.py
@@ -44,8 +44,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('read') == (True, True, True)
     assert check_access('create') == (True, True, False)
     assert check_access('update') == (True, False, False)
diff --git a/ForgeFiles/forgefiles/tests/test_files_roles.py 
b/ForgeFiles/forgefiles/tests/test_files_roles.py
index 1bce3c1fb..4f20c34d6 100644
--- a/ForgeFiles/forgefiles/tests/test_files_roles.py
+++ b/ForgeFiles/forgefiles/tests/test_files_roles.py
@@ -44,8 +44,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('read') == (True, True, True)
     assert check_access('create') == (True, False, False)
     assert check_access('update') == (True, False, False)
diff --git a/ForgeShortUrl/forgeshorturl/main.py 
b/ForgeShortUrl/forgeshorturl/main.py
index 5163cf5ee..adae9518d 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -81,7 +81,7 @@ class ForgeShortUrlApp(Application):
 
     def is_visible_to(self, user):
         '''Whether the user can view the app.'''
-        return has_access(c.project, 'create')(user=user)
+        return has_access(c.project, 'create', user)
 
     @property
     @h.exceptionless([], log)
diff --git a/ForgeTracker/forgetracker/tests/test_tracker_roles.py 
b/ForgeTracker/forgetracker/tests/test_tracker_roles.py
index 086e2796f..295dbd144 100644
--- a/ForgeTracker/forgetracker/tests/test_tracker_roles.py
+++ b/ForgeTracker/forgetracker/tests/test_tracker_roles.py
@@ -40,8 +40,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('configure') == (True, False, False)
     assert check_access('read') == (True, True, True)
     assert check_access('update') == (True, False, False)
diff --git a/ForgeTracker/forgetracker/tracker_main.py 
b/ForgeTracker/forgetracker/tracker_main.py
index 6bef6c747..31f3bed10 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -273,7 +273,7 @@ class ForgeTrackerApp(Application):
         return TM.Globals.query.get(app_config_id=self.config._id)
 
     def has_access(self, user, topic):
-        return has_access(c.app, 'post')(user=user)
+        return has_access(c.app, 'post', user)
 
     def handle_message(self, topic, message):
         log.info('Message from %s (%s)',
@@ -834,7 +834,7 @@ class RootController(BaseController, FeedController):
     @validate(validators=search_validators)
     def search(self, q=None, query=None, project=None, columns=None, page=0, 
sort=None,
                deleted=False, filter=None, **kw):
-        require(has_access(c.app, 'read'))
+        require_access(c.app, 'read')
 
         if deleted and not has_access(c.app, 'delete'):
             deleted = False
@@ -1961,7 +1961,7 @@ class MilestoneController(BaseController):
         deleted=validators.StringBool(if_empty=False)))
     def index(self, q=None, columns=None, page=0, query=None, sort=None,
               deleted=False, filter=None, **kw):
-        require(has_access(c.app, 'read'))
+        require_access(c.app, 'read')
         show_deleted = [False]
         if deleted and has_access(c.app, 'delete'):
             show_deleted = [False, True]
diff --git a/ForgeWiki/forgewiki/tests/test_wiki_roles.py 
b/ForgeWiki/forgewiki/tests/test_wiki_roles.py
index 56a964ddc..6feb7b301 100644
--- a/ForgeWiki/forgewiki/tests/test_wiki_roles.py
+++ b/ForgeWiki/forgewiki/tests/test_wiki_roles.py
@@ -40,8 +40,12 @@ def test_role_assignments():
     anon = M.User.anonymous()
 
     def check_access(perm):
-        pred = security.has_access(c.app, perm)
-        return pred(user=admin), pred(user=user), pred(user=anon)
+        return (
+            security.has_access(c.app, perm, admin),
+            security.has_access(c.app, perm, user),
+            security.has_access(c.app, perm, anon),
+        )
+
     assert check_access('configure') == (True, False, False)
     assert check_access('read') == (True, True, True)
     assert check_access('create') == (True, False, False)
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f4571e137..f1e8a4a3b 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -130,7 +130,7 @@ class ForgeWikiApp(Application):
         self.admin = WikiAdminController(self)
 
     def has_access(self, user, topic):
-        return has_access(c.app, 'post')(user=user)
+        return has_access(c.app, 'post', user)
 
     def handle_message(self, topic, message):
         log.info('Message from %s (%s)',

Reply via email to