fix: Improve rights management exception handling

- Add fallback permission object when Permission.DoesNotExist
- Create proper display name from field_name for missing permissions
- Prevents raw Django field objects from being displayed in template
This commit is contained in:
2025-10-05 22:46:44 +02:00
parent 004fcb23ae
commit efd0088124
25 changed files with 40348 additions and 4 deletions

View File

@@ -1423,8 +1423,14 @@ class UserPermissionForm(forms.Form):
(field_name, field, permission)
)
except Permission.DoesNotExist:
# Fallback for permissions that don't exist
groups["system"]["permissions"].append((field_name, field, None))
# Create a fallback permission-like object with proper display
class FallbackPermission:
def __init__(self, field_name):
self.name = field_name.replace('_', ' ').title()
self.codename = field_name
fallback_perm = FallbackPermission(field_name)
groups["system"]["permissions"].append((field_name, field, fallback_perm))
return groups