mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Misc cleanup
This commit is contained in:
parent
56eb5d28d1
commit
7c0fbd1703
@ -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):
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 %}#}
|
||||
{# <button type="submit" name="_edit"#}
|
||||
{# {% formaction %}="{% url bulk_edit_view %}?device={{ object.pk }}&return_url={{ return_url }}"#}
|
||||
{# class="btn btn-warning">#}
|
||||
{# <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected#}
|
||||
{# </button>#}
|
||||
{# {% endif %}#}
|
||||
{# {% endwith %}#}
|
||||
{# {% with bulk_rename_view=child_model|validated_viewname:"bulk_rename" %}#}
|
||||
{# {% if 'bulk_rename' in actions and bulk_rename_view %}#}
|
||||
{# <button type="submit" name="_rename"#}
|
||||
{# {% formaction %}="{% url bulk_rename_view %}?return_url={{ return_url }}"#}
|
||||
{# class="btn btn-outline-warning">#}
|
||||
{# <i class="mdi mdi-pencil-outline" aria-hidden="true"></i> Rename Selected#}
|
||||
{# </button>#}
|
||||
{# {% endif %}#}
|
||||
{# {% endwith %}#}
|
||||
{#{% endblock bulk_edit_controls %}#}
|
@ -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 %}
|
||||
<button type="submit" name="_edit"
|
||||
{% formaction %}="{% url bulk_edit_view %}?device={{ object.pk }}&return_url={{ return_url }}"
|
||||
class="btn btn-warning">
|
||||
<i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% with bulk_rename_view=child_model|validated_viewname:"bulk_rename" %}
|
||||
{% if 'bulk_rename' in actions and bulk_rename_view %}
|
||||
<button type="submit" name="_rename"
|
||||
{% formaction %}="{% url bulk_rename_view %}?return_url={{ return_url }}"
|
||||
class="btn btn-outline-warning">
|
||||
<i class="mdi mdi-pencil-outline" aria-hidden="true"></i> Rename Selected
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endblock bulk_edit_controls %}
|
||||
|
@ -40,36 +40,7 @@ Context:
|
||||
{% for name, action in actions.items %}
|
||||
{% bulk_action_button action model %}
|
||||
{% endfor %}
|
||||
{# <div class="btn-group" role="group">#}
|
||||
{# 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 %}#}
|
||||
{# <button type="submit" name="_edit"#}
|
||||
{# {% formaction %}="{% url bulk_edit_view %}?return_url={{ return_url }}"#}
|
||||
{# class="btn btn-warning">#}
|
||||
{# <i class="mdi mdi-pencil" aria-hidden="true"></i> {% trans "Edit Selected" %}#}
|
||||
{# </button>#}
|
||||
{# {% endif %}#}
|
||||
{# {% endwith %}#}
|
||||
{# {% endblock bulk_edit_controls %}#}
|
||||
{# </div>#}
|
||||
{# <div class="btn-group" role="group">#}
|
||||
{# 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 %}#}
|
||||
{# <button type="submit"#}
|
||||
{# {% formaction %}="{% url bulk_delete_view %}?return_url={{ return_url }}"#}
|
||||
{# class="btn btn-danger">#}
|
||||
{# <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> {% trans "Delete Selected" %}#}
|
||||
{# </button>#}
|
||||
{# {% endif %}#}
|
||||
{# {% endwith %}#}
|
||||
{# {% endblock bulk_delete_controls %}#}
|
||||
{# </div>#}
|
||||
{# Other bulk action buttons #}
|
||||
{% block bulk_extra_controls %}{% endblock %}
|
||||
{% block bulk_extra_controls %}{% endblock %}
|
||||
{% endblock bulk_controls %}
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,14 +0,0 @@
|
||||
{% extends 'generic/object_children.html' %}
|
||||
{% load helpers %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block bulk_edit_controls %}
|
||||
{{ block.super }}
|
||||
{% if 'bulk_rename' in actions %}
|
||||
<button type="submit" name="_rename"
|
||||
{% formaction %}="{% url 'virtualization:virtualdisk_bulk_rename' %}?return_url={{ return_url }}"
|
||||
class="btn btn-outline-warning">
|
||||
<i class="mdi mdi-pencil-outline" aria-hidden="true"></i> {% trans "Rename" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endblock bulk_edit_controls %}
|
Loading…
Reference in New Issue
Block a user