-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v4.3.2
Feature type
New functionality
Proposed functionality
Provide a mechanism for canonically declaring bulk action support for individual models. Currently, NetBox supports bulk edit and bulk delete functionality by default. Certain models, such as device components, support additional actions such as bulk renaming and bulk disconnecting. However, this is accomplished using customized templates in a nonstandard way.
We can implement a form of lightweight API to support arbitrary bulk operations for any model, obviating the need for customization in views and templates. This could be as simple as inheriting a base class:
class BulkEdit(BulkOperation):
verb = _('Edit')
button_class = 'warning'
view_name = 'bulk_edit'
This class could be responsible for evaluating user permissions (based on the declared set of actions for a model), resolving the view, and rendering the UI button. Bulk operations could be declared under each generic view, with the ability to be overridden where needed:
class SiteListView(generic.ObjectListView):
bulk_actions = (BulkEdit, BulkRename, BulkDelete)
It might also be feasible to extend view registration (register_model_view()
) to automatically enable bulk operations.
Use case
This will unlock the implementation of bulk operations beyond the defaults (bulk edit & bulk delete) for more models.
Database changes
None
External dependencies
None