fix: Use bound fields in rights management system

- Replace raw field objects with bound fields in get_permission_groups()
- Bound fields render properly as HTML checkboxes in templates
- Fixes display of Django field object strings instead of actual form inputs
- Rights management system now shows proper checkboxes with permission names
This commit is contained in:
2025-10-05 23:03:56 +02:00
parent efd0088124
commit ca3bf0f296

View File

@@ -1349,6 +1349,9 @@ class UserPermissionForm(forms.Form):
label = permission.name.lower()
codename = permission.codename.lower()
# Get bound field for proper template rendering
bound_field = self[field_name]
# More precise categorization based on both name and codename
if (
any(
@@ -1365,7 +1368,7 @@ class UserPermissionForm(forms.Form):
or "view_" in codename
):
groups["entities"]["permissions"].append(
(field_name, field, permission)
(field_name, bound_field, permission)
)
elif (
any(
@@ -1374,7 +1377,7 @@ class UserPermissionForm(forms.Form):
or "dokument" in label
):
groups["documents"]["permissions"].append(
(field_name, field, permission)
(field_name, bound_field, permission)
)
elif any(
word in codename
@@ -1394,7 +1397,7 @@ class UserPermissionForm(forms.Form):
]
):
groups["financial"]["permissions"].append(
(field_name, field, permission)
(field_name, bound_field, permission)
)
elif any(
word in codename
@@ -1416,11 +1419,11 @@ class UserPermissionForm(forms.Form):
]
):
groups["administration"]["permissions"].append(
(field_name, field, permission)
(field_name, bound_field, permission)
)
else:
groups["system"]["permissions"].append(
(field_name, field, permission)
(field_name, bound_field, permission)
)
except Permission.DoesNotExist:
# Create a fallback permission-like object with proper display
@@ -1430,7 +1433,8 @@ class UserPermissionForm(forms.Form):
self.codename = field_name
fallback_perm = FallbackPermission(field_name)
groups["system"]["permissions"].append((field_name, field, fallback_perm))
bound_field = self[field_name] # Get bound field for exception case too
groups["system"]["permissions"].append((field_name, bound_field, fallback_perm))
return groups