mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
Rename bulk attr to multi
This commit is contained in:
parent
759ac64a1b
commit
0da5000a2c
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -37,7 +37,7 @@ Context:
|
||||
</div>
|
||||
<div class="d-print-none mt-2">
|
||||
{% block bulk_controls %}
|
||||
{% action_buttons actions model bulk=True %}
|
||||
{% action_buttons actions model multi=True %}
|
||||
{% block bulk_extra_controls %}{% endblock %}
|
||||
{% endblock bulk_controls %}
|
||||
</div>
|
||||
|
@ -84,7 +84,7 @@ Context:
|
||||
</label>
|
||||
</div>
|
||||
<div class="bulk-action-buttons">
|
||||
{% action_buttons actions model bulk=True %}
|
||||
{% action_buttons actions model multi=True %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -113,7 +113,7 @@ Context:
|
||||
{% block bulk_buttons %}
|
||||
<div class="bulk-action-buttons">
|
||||
{% block extra_bulk_buttons %}{% endblock %}
|
||||
{% action_buttons actions model bulk=True %}
|
||||
{% action_buttons actions model multi=True %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user