Add PermissionCheck dataclass with parent/child fields, refs #2528

Instead of logging permission checks as dicts with a 'resource' key,
use a typed dataclass with separate parent and child fields.

Changes:
- Created PermissionCheck dataclass in app.py
- Updated permission check logging to use dataclass
- Updated PermissionsDebugView to use dataclass attributes
- Updated PermissionCheckView to check parent/child instead of resource
- Updated permissions_debug.html template to display parent/child
- Updated test expectations to use dataclass attributes

This provides better type safety and cleaner separation between
parent and child resource identifiers.
This commit is contained in:
Simon Willison 2025-10-25 09:59:21 -07:00
commit 10ea23a59c
4 changed files with 37 additions and 34 deletions

View file

@ -1259,9 +1259,10 @@ async def test_actor_restrictions(
"response_status": response.status_code,
"checks": [
{
"action": check["action"],
"resource": check["resource"],
"result": check["result"],
"action": check.action,
"parent": check.parent,
"child": check.child,
"result": check.result,
}
for check in perms_ds._permission_checks
],