mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-10 19:27:05 +02:00
Consolidate ObjectPermission detail view actions panel
Merge ObjectPermissionActionsPanel and ObjectPermissionCustomActionsPanel into a single Actions panel that shows CRUD booleans and all registered actions in one table, matching the form's consolidated layout. Also fix data-object-types-selected attribute value (True -> 'true') and update plugin docs to show Meta.permissions as the primary registration approach.
This commit is contained in:
@@ -6,7 +6,22 @@ For example, a plugin might define a "sync" action for a model that syncs data f
|
||||
|
||||
## Registering Model Actions
|
||||
|
||||
To register custom actions for a model, call `register_model_actions()` in your plugin's `ready()` method:
|
||||
The preferred way to register custom actions is via Django's `Meta.permissions` on the model class. NetBox will automatically register these as model actions when the app is loaded:
|
||||
|
||||
```python
|
||||
from netbox.models import NetBoxModel
|
||||
|
||||
class MyModel(NetBoxModel):
|
||||
# ...
|
||||
|
||||
class Meta:
|
||||
permissions = [
|
||||
('sync', 'Synchronize data from external source'),
|
||||
('export', 'Export data to external system'),
|
||||
]
|
||||
```
|
||||
|
||||
For dynamic registration (e.g. when actions depend on runtime state), you can call `register_model_actions()` directly, typically in your plugin's `ready()` method:
|
||||
|
||||
```python
|
||||
# __init__.py
|
||||
@@ -29,7 +44,7 @@ class MyPluginConfig(PluginConfig):
|
||||
config = MyPluginConfig
|
||||
```
|
||||
|
||||
Once registered, these actions will appear grouped under your model's name when creating or editing an ObjectPermission that includes your model as an object type.
|
||||
Once registered, these actions appear as checkboxes in a flat list when creating or editing an ObjectPermission.
|
||||
|
||||
::: utilities.permissions.ModelAction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user