diff --git a/netbox/core/object_actions.py b/netbox/core/object_actions.py index b65003764..fc538f205 100644 --- a/netbox/core/object_actions.py +++ b/netbox/core/object_actions.py @@ -13,6 +13,6 @@ class BulkSync(ObjectAction): """ name = 'bulk_sync' label = _('Sync Data') - bulk = True + multi = True permissions_required = {'sync'} template_name = 'buttons/bulk_sync.html' diff --git a/netbox/dcim/object_actions.py b/netbox/dcim/object_actions.py index d9a124733..2b924e869 100644 --- a/netbox/dcim/object_actions.py +++ b/netbox/dcim/object_actions.py @@ -13,6 +13,6 @@ class BulkDisconnect(ObjectAction): """ name = 'bulk_disconnect' label = _('Disconnect Selected') - bulk = True + multi = True permissions_required = {'change'} template_name = 'buttons/bulk_disconnect.html' diff --git a/netbox/netbox/object_actions.py b/netbox/netbox/object_actions.py index 1a72e124f..3475a862d 100644 --- a/netbox/netbox/object_actions.py +++ b/netbox/netbox/object_actions.py @@ -18,9 +18,19 @@ __all__ = ( class ObjectAction: + """ + Base class for single- and multi-object operations. + + Params: + name: The action name + label: Human-friendly label for the rendered button + multi: Set to True if this action is performed by selecting multiple objects (i.e. using a table) + permissions_required: The set of permissions a user must have to perform the action + url_kwargs: The set of URL keyword arguments to pass when resolving the view's URL + """ name = '' label = None - bulk = False + multi = False permissions_required = set() url_kwargs = [] @@ -117,7 +127,7 @@ class BulkEdit(ObjectAction): """ name = 'bulk_edit' label = _('Edit Selected') - bulk = True + multi = True permissions_required = {'change'} template_name = 'buttons/bulk_edit.html' @@ -128,7 +138,7 @@ class BulkRename(ObjectAction): """ name = 'bulk_rename' label = _('Rename Selected') - bulk = True + multi = True permissions_required = {'change'} template_name = 'buttons/bulk_rename.html' @@ -139,6 +149,6 @@ class BulkDelete(ObjectAction): """ name = 'bulk_delete' label = _('Delete Selected') - bulk = True + multi = True permissions_required = {'delete'} template_name = 'buttons/bulk_delete.html' diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index 477a36e90..08b060634 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -152,13 +152,13 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin): # Determine the available actions actions = self.get_permitted_actions(request.user) - has_bulk_actions = any(action.bulk for action in actions) + has_table_actions = any(action.multi for action in actions) if 'export' in request.GET: # Export the current table view if request.GET['export'] == 'table': - table = self.get_table(self.queryset, request, has_bulk_actions) + table = self.get_table(self.queryset, request, has_table_actions) columns = [name for name, _ in table.selected_columns] return self.export_table(table, columns) @@ -176,11 +176,11 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin): # Fall back to default table/YAML export else: - table = self.get_table(self.queryset, request, has_bulk_actions) + table = self.get_table(self.queryset, request, has_table_actions) return self.export_table(table) # Render the objects table - table = self.get_table(self.queryset, request, has_bulk_actions) + table = self.get_table(self.queryset, request, has_table_actions) # If this is an HTMX request, return only the rendered table HTML if htmx_partial(request): diff --git a/netbox/netbox/views/generic/object_views.py b/netbox/netbox/views/generic/object_views.py index 989e1f7a9..67517b38b 100644 --- a/netbox/netbox/views/generic/object_views.py +++ b/netbox/netbox/views/generic/object_views.py @@ -143,10 +143,10 @@ class ObjectChildrenView(ObjectView, ActionsMixin, TableMixin): # Determine the available actions actions = self.get_permitted_actions(request.user, model=self.child_model) - has_bulk_actions = any(action.bulk for action in actions) + has_table_actions = any(action.multi for action in actions) table_data = self.prep_table_data(request, child_objects, instance) - table = self.get_table(table_data, request, has_bulk_actions) + table = self.get_table(table_data, request, has_table_actions) # If this is an HTMX request, return only the rendered table HTML if htmx_partial(request): diff --git a/netbox/templates/generic/object_children.html b/netbox/templates/generic/object_children.html index ff422a06f..a95f6ed0f 100644 --- a/netbox/templates/generic/object_children.html +++ b/netbox/templates/generic/object_children.html @@ -37,7 +37,7 @@ Context:
{% block bulk_controls %} - {% action_buttons actions model bulk=True %} + {% action_buttons actions model multi=True %} {% block bulk_extra_controls %}{% endblock %} {% endblock bulk_controls %}
diff --git a/netbox/templates/generic/object_list.html b/netbox/templates/generic/object_list.html index a9aa0f678..8bce75340 100644 --- a/netbox/templates/generic/object_list.html +++ b/netbox/templates/generic/object_list.html @@ -84,7 +84,7 @@ Context:
- {% action_buttons actions model bulk=True %} + {% action_buttons actions model multi=True %}
@@ -113,7 +113,7 @@ Context: {% block bulk_buttons %}
{% block extra_bulk_buttons %}{% endblock %} - {% action_buttons actions model bulk=True %} + {% action_buttons actions model multi=True %}
{% endblock %} diff --git a/netbox/utilities/templatetags/buttons.py b/netbox/utilities/templatetags/buttons.py index 3a19ccf62..c1003d249 100644 --- a/netbox/utilities/templatetags/buttons.py +++ b/netbox/utilities/templatetags/buttons.py @@ -29,10 +29,10 @@ register = template.Library() @register.simple_tag(takes_context=True) -def action_buttons(context, actions, obj, bulk=False): +def action_buttons(context, actions, obj, multi=False): buttons = [ loader.render_to_string(action.template_name, action.get_context(context, obj)) - for action in actions if action.bulk == bulk + for action in actions if action.multi == multi ] return mark_safe(''.join(buttons))