Conversation
Also datasette.permissions is now a dict, not a list
…_are_documented - refs #1939
I tried to fix a failing test here, but broke another one.
|
Here's my first test failure: It looks like I've broken the |
|
I'm going to revert that last commit, see if I can get the tests running again and then apply the changes a line at a time to figure out which ones broke things. |
|
It's this change which triggers the failures: diff --git a/datasette/app.py b/datasette/app.py
index 760063d5..defa9688 100644
--- a/datasette/app.py
+++ b/datasette/app.py
@@ -707,9 +707,12 @@ class Datasette:
)
return crumbs
- async def permission_allowed(self, actor, action, resource=None, default=False):
+ async def permission_allowed(self, actor, action, resource=None, default=None):
"""Check permissions using the permissions_allowed plugin hook"""
result = None
+ # Use default from registered permission, if available
+ if default is None and action in self.permissions:
+ default = self.permissions[action].default
for check in pm.hook.permission_allowed(
datasette=self,
actor=actor, |
Codecov ReportBase: 92.00% // Head: 92.03% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1940 +/- ##
==========================================
+ Coverage 92.00% 92.03% +0.02%
==========================================
Files 38 38
Lines 5378 5396 +18
==========================================
+ Hits 4948 4966 +18
Misses 430 430
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
Actually one last thing: I said that the error would only occur if the permissions differed in some way. |
|
This PR ended up bundling part of the implementation of: I'm going to be bad an NOT untangle that from this before I merge it. |
Refs #1939
From this comment: #1939 (comment)
check_permission_actions_are_documentedtest inconftest.pyPermissions(and update tests and docs)datasette.permissionsdictionarydefault=provided in call topermission_allowed()then use default fromdatasette.permissionslistdefault=from a bunch of places📚 Documentation preview 📚: https://datasette--1940.org.readthedocs.build/en/1940/