Address additional bot review feedback

- clean() collects all validation errors before raising instead of stopping at the first
- Fix stale admin docs (still referenced "Custom actions" and "grouped by model")
This commit is contained in:
Jason Novinger
2026-04-03 08:07:42 -05:00
parent e9be6e4178
commit 4c291f0463
2 changed files with 10 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ There are four core actions that can be permitted for each type of object within
In addition to these, permissions can also grant custom actions that may be required by a specific model or plugin. For example, the `sync` action for data sources allows a user to synchronize data from a remote source, and the `render_config` action for devices and virtual machines allows rendering configuration templates.
Some models have registered custom actions that appear as checkboxes when creating or editing a permission. These are grouped by model under "Custom actions" in the permission form. Additional custom actions (such as those not yet registered or for backwards compatibility) can be entered manually in the "Additional actions" field.
Some models have registered actions that appear as checkboxes in the "Actions" section when creating or editing a permission. These are shown in a flat list alongside the built-in CRUD actions. Additional actions (such as those not yet registered by a plugin, or for backwards compatibility) can be entered manually in the "Additional actions" field.
!!! note
Internally, all actions granted by a permission (both built-in and custom) are stored as strings in an array field named `actions`.

View File

@@ -480,17 +480,20 @@ class ObjectPermissionForm(forms.ModelForm):
action_model_keys = get_action_model_map(dict(registry['model_actions']))
# Validate each selected action is supported by at least one selected object type
errors = []
final_actions = []
for action_name in registered_actions:
supported_models = action_model_keys.get(action_name, set())
if not supported_models & selected_models:
raise forms.ValidationError({
'registered_actions': _(
'Action "{action}" is not supported by any of the selected object types.'
).format(action=action_name)
})
if action_name not in final_actions:
errors.append(
_('Action "{action}" is not supported by any of the selected object types.').format(
action=action_name
)
)
elif action_name not in final_actions:
final_actions.append(action_name)
if errors:
raise forms.ValidationError({'registered_actions': errors})
# Append any of the selected CRUD checkboxes to the actions list
for action in RESERVED_ACTIONS: