From 476194f0aaefb5602ab942eb184af87a0b493835 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Mon, 28 Oct 2024 12:04:45 -0700 Subject: [PATCH] 17460 make ModuleType / DeviceType bulk buttons consistent (#17463) * 17460 make ModuleType / DeviceType bulk buttons consistent * 17460 refactor moduletype/devicetype to use standardized object_children * 17460 refactor moduletype/devicetype to use standardized object_children * 17460 refactor moduletype/devicetype to use standardized object_children --- .../dcim/devicetype/component_templates.html | 15 +--- .../dcim/inc/devicetype_breadcrumbs.html | 2 + .../dcim/inc/moduletype_buttons.html | 38 ++++++++++ netbox/templates/dcim/moduletype.html | 13 +++- netbox/templates/dcim/moduletype/base.html | 48 ------------ .../dcim/moduletype/component_templates.html | 73 +++++++++---------- 6 files changed, 86 insertions(+), 103 deletions(-) create mode 100644 netbox/templates/dcim/inc/devicetype_breadcrumbs.html create mode 100644 netbox/templates/dcim/inc/moduletype_buttons.html delete mode 100644 netbox/templates/dcim/moduletype/base.html diff --git a/netbox/templates/dcim/devicetype/component_templates.html b/netbox/templates/dcim/devicetype/component_templates.html index df9789c00..291c7c988 100644 --- a/netbox/templates/dcim/devicetype/component_templates.html +++ b/netbox/templates/dcim/devicetype/component_templates.html @@ -18,21 +18,8 @@ {% endif %} {% endwith %} {% endblock bulk_edit_controls %} - -{% block bulk_extra_controls %} - {{ block.super }} - {% if request.user|can_add:child_model %} -
- - - {% trans "Add" %} {{ title }} - -
- {% endif %} -{% endblock bulk_extra_controls %} - diff --git a/netbox/templates/dcim/inc/devicetype_breadcrumbs.html b/netbox/templates/dcim/inc/devicetype_breadcrumbs.html new file mode 100644 index 000000000..02f326ddc --- /dev/null +++ b/netbox/templates/dcim/inc/devicetype_breadcrumbs.html @@ -0,0 +1,2 @@ + + diff --git a/netbox/templates/dcim/inc/moduletype_buttons.html b/netbox/templates/dcim/inc/moduletype_buttons.html new file mode 100644 index 000000000..9ec34f412 --- /dev/null +++ b/netbox/templates/dcim/inc/moduletype_buttons.html @@ -0,0 +1,38 @@ +{% load buttons %} +{% load helpers %} +{% load i18n %} + + +{% if perms.dcim.change_devicetype %} + +{% endif %} diff --git a/netbox/templates/dcim/moduletype.html b/netbox/templates/dcim/moduletype.html index 110db8e20..f57c501cf 100644 --- a/netbox/templates/dcim/moduletype.html +++ b/netbox/templates/dcim/moduletype.html @@ -1,9 +1,20 @@ -{% extends 'dcim/moduletype/base.html' %} +{% extends 'generic/object.html' %} {% load buttons %} {% load helpers %} {% load plugins %} {% load i18n %} +{% block title %}{{ object.manufacturer }} {{ object.model }}{% endblock %} + +{% block breadcrumbs %} + {{ block.super }} + {% include 'dcim/inc/devicetype_breadcrumbs.html' %} +{% endblock %} + +{% block extra_controls %} + {% include 'dcim/inc/moduletype_buttons.html' %} +{% endblock %} + {% block content %}
diff --git a/netbox/templates/dcim/moduletype/base.html b/netbox/templates/dcim/moduletype/base.html deleted file mode 100644 index b7d9026d5..000000000 --- a/netbox/templates/dcim/moduletype/base.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'generic/object.html' %} -{% load buttons %} -{% load helpers %} -{% load plugins %} -{% load i18n %} - -{% block title %}{{ object.manufacturer }} {{ object.model }}{% endblock %} - -{% block breadcrumbs %} - {{ block.super }} - -{% endblock %} - -{% block extra_controls %} - {% if perms.dcim.change_devicetype %} - - {% endif %} -{% endblock %} diff --git a/netbox/templates/dcim/moduletype/component_templates.html b/netbox/templates/dcim/moduletype/component_templates.html index 9c4d59cba..8f4c24478 100644 --- a/netbox/templates/dcim/moduletype/component_templates.html +++ b/netbox/templates/dcim/moduletype/component_templates.html @@ -1,44 +1,37 @@ -{% extends 'dcim/moduletype/base.html' %} +{% extends 'generic/object_children.html' %} {% load render_table from django_tables2 %} {% load helpers %} {% load i18n %} -{% block content %} - {% if perms.dcim.change_moduletype %} -
- {% csrf_token %} -
-
- {% include 'htmx/table.html' %} -
- -
-
- {% else %} -
-

{{ title }}

-
- {% include 'htmx/table.html' %} -
-
- {% endif %} -{% endblock content %} +{% block title %}{{ object.manufacturer }} {{ object.model }}{% endblock %} + +{% block breadcrumbs %} + {{ block.super }} + {% include 'dcim/inc/devicetype_breadcrumbs.html' %} +{% endblock %} + +{% 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 %} +