diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 5614310f5..582db2701 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -59,7 +59,6 @@ class DeviceComponentsView(generic.ObjectChildrenView): class DeviceTypeComponentsView(generic.ObjectChildrenView): actions = (Edit, Delete, BulkEdit, BulkRename, BulkDelete) queryset = DeviceType.objects.all() - template_name = 'dcim/devicetype/component_templates.html' viewname = None # Used for return_url resolution def get_children(self, request, parent): @@ -74,7 +73,6 @@ class DeviceTypeComponentsView(generic.ObjectChildrenView): class ModuleTypeComponentsView(generic.ObjectChildrenView): queryset = ModuleType.objects.all() actions = (Edit, Delete, BulkEdit, BulkRename, BulkDelete) - template_name = 'dcim/moduletype/component_templates.html' viewname = None # Used for return_url resolution def get_children(self, request, parent): diff --git a/netbox/netbox/object_actions.py b/netbox/netbox/object_actions.py index 123e64f84..2eb99b4c2 100644 --- a/netbox/netbox/object_actions.py +++ b/netbox/netbox/object_actions.py @@ -25,11 +25,17 @@ class ObjectAction: url_kwargs = [] @classmethod - def get_context(cls, context, obj): + def get_url(cls, obj): viewname = f'{obj._meta.app_label}:{obj._meta.model_name}_{cls.name}' - url = reverse(viewname, kwargs={kwarg: getattr(obj, kwarg) for kwarg in cls.url_kwargs}) + kwargs = { + kwarg: getattr(obj, kwarg) for kwarg in cls.url_kwargs + } + return reverse(viewname, kwargs=kwargs) + + @classmethod + def get_context(cls, context, obj): return { - 'url': url, + 'url': cls.get_url(obj), 'label': cls.label, } diff --git a/netbox/netbox/views/generic/mixins.py b/netbox/netbox/views/generic/mixins.py index f43512b09..e4d300136 100644 --- a/netbox/netbox/views/generic/mixins.py +++ b/netbox/netbox/views/generic/mixins.py @@ -19,6 +19,7 @@ class ActionsMixin: Standard actions include: add, import, export, bulk_edit, and bulk_delete. Some views extend this default map with custom actions, such as bulk_sync. """ + actions = tuple() # TODO: Remove in NetBox v4.6 @staticmethod diff --git a/netbox/templates/dcim/devicetype/component_templates.html b/netbox/templates/dcim/devicetype/component_templates.html deleted file mode 100644 index 4d1361942..000000000 --- a/netbox/templates/dcim/devicetype/component_templates.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends 'generic/object_children.html' %} -{% load helpers %} -{% load i18n %} -{% load perms %} - -{#{% block bulk_edit_controls %}#} -{# {% with bulk_edit_view=child_model|validated_viewname:"bulk_edit" %}#} -{# {% if 'bulk_edit' in actions and bulk_edit_view %}#} -{# #} -{# {% endif %}#} -{# {% endwith %}#} -{# {% with bulk_rename_view=child_model|validated_viewname:"bulk_rename" %}#} -{# {% if 'bulk_rename' in actions and bulk_rename_view %}#} -{# #} -{# {% endif %}#} -{# {% endwith %}#} -{#{% endblock bulk_edit_controls %}#} diff --git a/netbox/templates/dcim/moduletype/component_templates.html b/netbox/templates/dcim/moduletype/component_templates.html deleted file mode 100644 index 3cee0bbd9..000000000 --- a/netbox/templates/dcim/moduletype/component_templates.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends 'generic/object_children.html' %} -{% load render_table from django_tables2 %} -{% load helpers %} -{% load i18n %} - -{% block extra_controls %} - {% include 'dcim/inc/moduletype_buttons.html' %} -{% endblock %} - -{% block bulk_edit_controls %} - {% with bulk_edit_view=child_model|validated_viewname:"bulk_edit" %} - {% if 'bulk_edit' in actions and bulk_edit_view %} - - {% endif %} - {% endwith %} - {% with bulk_rename_view=child_model|validated_viewname:"bulk_rename" %} - {% if 'bulk_rename' in actions and bulk_rename_view %} - - {% endif %} - {% endwith %} -{% endblock bulk_edit_controls %} - diff --git a/netbox/templates/generic/object_children.html b/netbox/templates/generic/object_children.html index 93d7323e4..fe68d4231 100644 --- a/netbox/templates/generic/object_children.html +++ b/netbox/templates/generic/object_children.html @@ -40,36 +40,7 @@ Context: {% for name, action in actions.items %} {% bulk_action_button action model %} {% endfor %} -{#
#} - {# Bulk edit buttons #} -{# {% block bulk_edit_controls %}#} -{# {% with bulk_edit_view=child_model|validated_viewname:"bulk_edit" %}#} -{# {% if 'bulk_edit' in actions and bulk_edit_view %}#} -{# #} -{# {% endif %}#} -{# {% endwith %}#} -{# {% endblock bulk_edit_controls %}#} -{#
#} -{#
#} - {# Bulk delete buttons #} -{# {% block bulk_delete_controls %}#} -{# {% with bulk_delete_view=child_model|validated_viewname:"bulk_delete" %}#} -{# {% if 'bulk_delete' in actions and bulk_delete_view %}#} -{# #} -{# {% endif %}#} -{# {% endwith %}#} -{# {% endblock bulk_delete_controls %}#} -{#
#} - {# Other bulk action buttons #} - {% block bulk_extra_controls %}{% endblock %} + {% block bulk_extra_controls %}{% endblock %} {% endblock bulk_controls %} diff --git a/netbox/templates/virtualization/virtualmachine/virtual_disks.html b/netbox/templates/virtualization/virtualmachine/virtual_disks.html deleted file mode 100644 index 2637d851a..000000000 --- a/netbox/templates/virtualization/virtualmachine/virtual_disks.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends 'generic/object_children.html' %} -{% load helpers %} -{% load i18n %} - -{% block bulk_edit_controls %} - {{ block.super }} - {% if 'bulk_rename' in actions %} - - {% endif %} -{% endblock bulk_edit_controls %}