From fa014fcbf0aa03d7cdd822ff3aa38e2824773d48 Mon Sep 17 00:00:00 2001 From: Craig Pund Date: Thu, 30 Jun 2022 01:38:38 -0400 Subject: [PATCH 01/26] add device bulk rename view and url --- netbox/dcim/urls.py | 1 + netbox/dcim/views.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/netbox/dcim/urls.py b/netbox/dcim/urls.py index c5cd0fa65..f00bd73e1 100644 --- a/netbox/dcim/urls.py +++ b/netbox/dcim/urls.py @@ -248,6 +248,7 @@ urlpatterns = [ path('devices/import/', views.DeviceBulkImportView.as_view(), name='device_import'), path('devices/import/child-devices/', views.ChildDeviceBulkImportView.as_view(), name='device_import_child'), path('devices/edit/', views.DeviceBulkEditView.as_view(), name='device_bulk_edit'), + path('devices/rename/', views.DeviceBulkRenameView.as_view(), name='device_bulk_rename'), path('devices/delete/', views.DeviceBulkDeleteView.as_view(), name='device_bulk_delete'), path('devices//', views.DeviceView.as_view(), name='device'), path('devices//edit/', views.DeviceEditView.as_view(), name='device_edit'), diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 35a1056b2..28325bcfc 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1786,6 +1786,12 @@ class DeviceBulkDeleteView(generic.BulkDeleteView): table = tables.DeviceTable +class DeviceBulkRenameView(generic.BulkRenameView): + queryset = Device.objects.prefetch_related('tenant', 'site', 'rack', 'device_role', 'device_type__manufacturer') + filterset = filtersets.DeviceFilterSet + table = tables.DeviceTable + + # # Devices # From 5dff7433e854a09cb876602ce8220f8f5479a80a Mon Sep 17 00:00:00 2001 From: Craig Pund Date: Thu, 30 Jun 2022 01:38:53 -0400 Subject: [PATCH 02/26] add bulk device rename button to device_list --- netbox/templates/dcim/device_list.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netbox/templates/dcim/device_list.html b/netbox/templates/dcim/device_list.html index 60efc842e..e5dbe0d9c 100644 --- a/netbox/templates/dcim/device_list.html +++ b/netbox/templates/dcim/device_list.html @@ -2,6 +2,10 @@ {% block bulk_buttons %} {% if perms.dcim.change_device %} + + From 7d6882bec29f2ffe70a278cee99f0abc9216d498 Mon Sep 17 00:00:00 2001 From: Renato Almeida de Oliveira Date: Sat, 23 Jul 2022 20:24:33 +0000 Subject: [PATCH 06/26] Change display to Modal --- netbox/templates/ipam/prefix.html | 84 +++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/netbox/templates/ipam/prefix.html b/netbox/templates/ipam/prefix.html index caad547c4..ed2c3339b 100644 --- a/netbox/templates/ipam/prefix.html +++ b/netbox/templates/ipam/prefix.html @@ -143,34 +143,16 @@ {% endwith %} - {% if object.prefix.version == 4 %} - - - Network Mask - - - {{ object.prefix.netmask }} - - - - - Broadcast Address - - - {{ object.prefix.broadcast }} - - - - - Wildcard Mask - - - {{ object.prefix.hostmask }} - - - {% endif %} + {% if object.prefix.version == 4 %} + + {% endif %} {% include 'inc/panels/custom_fields.html' %} {% include 'inc/panels/tags.html' %} @@ -186,4 +168,54 @@ {% plugin_full_width_page object %} +{% if object.prefix.version == 4 %} + +{% endif %} {% endblock %} From 1c7ef73d1fcff334ff34dba2fff073c934a06c99 Mon Sep 17 00:00:00 2001 From: Dorian Bourgeoisat Date: Tue, 9 Aug 2022 14:20:42 +0200 Subject: [PATCH 07/26] Closes #8595: Added new PON interface types --- netbox/dcim/choices.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index 2e96f9c67..c91faf3da 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -814,6 +814,14 @@ class InterfaceTypeChoices(ChoiceSet): # ATM/DSL TYPE_XDSL = 'xdsl' + # PON + TYPE_GPON = 'gpon' + TYPE_XG_PON = 'xg-pon' + TYPE_XGS_PON = 'xgs-pon' + TYPE_TWDM_PON = 'twdm-pon' + TYPE_EPON = 'epon' + TYPE_10G_EPON = '10g-epon' + # Stacking TYPE_STACKWISE = 'cisco-stackwise' TYPE_STACKWISE_PLUS = 'cisco-stackwise-plus' @@ -950,6 +958,17 @@ class InterfaceTypeChoices(ChoiceSet): (TYPE_XDSL, 'xDSL'), ) ), + ( + 'PON', + ( + (TYPE_GPON, 'GPON (2.5 Gbps / 1.25 Gps)'), + (TYPE_XG_PON, 'XG-PON (10 Gbps / 2.5 Gbps)'), + (TYPE_XGS_PON, 'XGS-PON (10 Gbps)'), + (TYPE_TWDM_PON, 'TWDM-PON (NG-PON2) (4x10 Gbps)'), + (TYPE_EPON, 'EPON (1 Gbps)'), + (TYPE_10G_EPON, '10G-EPON (10 Gbps)'), + ) + ), ( 'Stacking', ( From 9a80a491c90bcdc3341a7c75f2f8bae93e32fba9 Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Thu, 11 Aug 2022 14:11:41 +0200 Subject: [PATCH 08/26] re-enable markdown in custom columns --- netbox/netbox/tables/columns.py | 25 +++++++++++++++++++++++++ netbox/netbox/tables/tables.py | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index f78b9f37c..cc20bdd0c 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -550,3 +550,28 @@ class MarkdownColumn(tables.TemplateColumn): def value(self, value): return value + + +class CustomFieldMarkdownColumn(tables.TemplateColumn): + """ + Render a Markdown string in a longtext custom column. + """ + template_code = """ + {% if value %} + {{ value|markdown }} + {% else %} + — + {% endif %} + """ + + def __init__(self, customfield, *args, **kwargs): + self.customfield = customfield + kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}') + kwargs['template_code'] = self.template_code + if 'verbose_name' not in kwargs: + kwargs['verbose_name'] = customfield.label or customfield.name + + super().__init__(*args, **kwargs) + + def value(self, value): + return value diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index 8c5fb039c..d55038c4d 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -7,6 +7,7 @@ from django.db.models.fields.related import RelatedField from django_tables2.data import TableQuerysetData from extras.models import CustomField, CustomLink +from extras.choices import CustomFieldTypeChoices from netbox.tables import columns from utilities.paginator import EnhancedPaginator, get_paginate_count @@ -180,7 +181,7 @@ class NetBoxTable(BaseTable): content_type = ContentType.objects.get_for_model(self._meta.model) custom_fields = CustomField.objects.filter(content_types=content_type) extra_columns.extend([ - (f'cf_{cf.name}', columns.CustomFieldColumn(cf)) for cf in custom_fields + (f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields ]) custom_links = CustomLink.objects.filter(content_type=content_type, enabled=True) extra_columns.extend([ From 6a687a9ed1027e2819391076195138c7babf9400 Mon Sep 17 00:00:00 2001 From: Craig Pund Date: Thu, 11 Aug 2022 15:16:01 -0400 Subject: [PATCH 09/26] not necessary to prefetch --- netbox/dcim/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 28325bcfc..bd693e392 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1787,7 +1787,7 @@ class DeviceBulkDeleteView(generic.BulkDeleteView): class DeviceBulkRenameView(generic.BulkRenameView): - queryset = Device.objects.prefetch_related('tenant', 'site', 'rack', 'device_role', 'device_type__manufacturer') + queryset = Device.objects.all() filterset = filtersets.DeviceFilterSet table = tables.DeviceTable From 5873ad95dc16db127298037b1af5093543583eff Mon Sep 17 00:00:00 2001 From: Craig Pund Date: Thu, 11 Aug 2022 15:16:42 -0400 Subject: [PATCH 10/26] handle objects without names --- netbox/netbox/views/generic/bulk_views.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index f17bc179d..e1f73b225 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -632,7 +632,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView): replace = form.cleaned_data['replace'] if form.cleaned_data['use_regex']: try: - obj.new_name = re.sub(find, replace, obj.name) + obj.new_name = re.sub(find, replace, obj.name or '') # Catch regex group reference errors except re.error: obj.new_name = obj.name @@ -676,9 +676,6 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView): else: form = self.form(initial={'pk': request.POST.getlist('pk')}) selected_objects = self.queryset.filter(pk__in=form.initial['pk']) - for object in selected_objects: - # Do something to raise error message to user - pass return render(request, self.template_name, { 'form': form, From 693ad700e83a49f8f9852bc4a952ed57811c10d4 Mon Sep 17 00:00:00 2001 From: Dorian Bourgeoisat <33571477+DorianXGH@users.noreply.github.com> Date: Fri, 12 Aug 2022 00:49:13 +0200 Subject: [PATCH 11/26] Swapping NG-PON2 as main name instead of TWDM-PON --- netbox/dcim/choices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index c91faf3da..1831ee8ae 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -818,7 +818,7 @@ class InterfaceTypeChoices(ChoiceSet): TYPE_GPON = 'gpon' TYPE_XG_PON = 'xg-pon' TYPE_XGS_PON = 'xgs-pon' - TYPE_TWDM_PON = 'twdm-pon' + TYPE_NG_PON2 = 'ng-pon2' TYPE_EPON = 'epon' TYPE_10G_EPON = '10g-epon' @@ -964,7 +964,7 @@ class InterfaceTypeChoices(ChoiceSet): (TYPE_GPON, 'GPON (2.5 Gbps / 1.25 Gps)'), (TYPE_XG_PON, 'XG-PON (10 Gbps / 2.5 Gbps)'), (TYPE_XGS_PON, 'XGS-PON (10 Gbps)'), - (TYPE_TWDM_PON, 'TWDM-PON (NG-PON2) (4x10 Gbps)'), + (TYPE_NG_PON2, 'NG-PON2 (TWDM-PON) (4x10 Gbps)'), (TYPE_EPON, 'EPON (1 Gbps)'), (TYPE_10G_EPON, '10G-EPON (10 Gbps)'), ) From e4fa8af47f7ae449bc490d927e5ac329a419e79b Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 12 Aug 2022 10:48:16 -0400 Subject: [PATCH 12/26] Changelog for #8595 --- docs/release-notes/version-3.2.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index c572328bc..824e99778 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -4,6 +4,7 @@ ### Enhancements +* [#8595](https://github.com/netbox-community/netbox/issues/8595) - Add PON interface types * [#9161](https://github.com/netbox-community/netbox/issues/9161) - Pretty print JSON custom field data when editing * [#9625](https://github.com/netbox-community/netbox/issues/9625) - Add phone & email details to contacts panel * [#9857](https://github.com/netbox-community/netbox/issues/9857) - Add clear button to quick search fields From ca0b21bef5723aedfffaacd90df32a41e965a1cb Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 12 Aug 2022 11:25:03 -0400 Subject: [PATCH 13/26] Closes #9980: Use standard table controls template for device interfaces list --- .../device/inc/interface_table_controls.html | 11 +++++++ netbox/templates/dcim/device/interfaces.html | 29 +------------------ netbox/templates/inc/table_controls_htmx.html | 26 ++++++++--------- 3 files changed, 25 insertions(+), 41 deletions(-) create mode 100644 netbox/templates/dcim/device/inc/interface_table_controls.html diff --git a/netbox/templates/dcim/device/inc/interface_table_controls.html b/netbox/templates/dcim/device/inc/interface_table_controls.html new file mode 100644 index 000000000..14e552439 --- /dev/null +++ b/netbox/templates/dcim/device/inc/interface_table_controls.html @@ -0,0 +1,11 @@ +{% extends 'inc/table_controls_htmx.html' %} + +{% block extra_table_controls %} + + +{% endblock extra_table_controls %} diff --git a/netbox/templates/dcim/device/interfaces.html b/netbox/templates/dcim/device/interfaces.html index 79a9d6b6f..94e38dbf3 100644 --- a/netbox/templates/dcim/device/interfaces.html +++ b/netbox/templates/dcim/device/interfaces.html @@ -4,34 +4,7 @@ {% load static %} {% block content %} -
-
-
- - -
-
-
-
- {% if request.user.is_authenticated %} - - {% endif %} - - -
-
-
+ {% include 'dcim/device/inc/interface_table_controls.html' with table_modal="DeviceInterfaceTable_config" %}
{% csrf_token %} diff --git a/netbox/templates/inc/table_controls_htmx.html b/netbox/templates/inc/table_controls_htmx.html index 099ad537e..6d6926d5d 100644 --- a/netbox/templates/inc/table_controls_htmx.html +++ b/netbox/templates/inc/table_controls_htmx.html @@ -1,22 +1,22 @@ {% load helpers %} -
-
-
+
+
+
- +
+ {% block extra_table_controls %}{% endblock %}
-
+
{% if request.user.is_authenticated and table_modal %} -
- -
+
+ +
{% endif %}
-
\ No newline at end of file +
From f942216f3f4931c0d1e835948478e976172713ab Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Sat, 13 Aug 2022 13:54:38 +0200 Subject: [PATCH 14/26] re-enable markup in longtext custom columns --- netbox/netbox/tables/columns.py | 10 ++++++++++ netbox/netbox/tables/tables.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index cc20bdd0c..8b961219f 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -418,6 +418,14 @@ class CustomFieldColumn(tables.Column): """ Display custom fields in the appropriate format. """ + template_code = """ + {% if value %} + {{ value|markdown }} + {% else %} + — + {% endif %} + """ + def __init__(self, customfield, *args, **kwargs): self.customfield = customfield kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}') @@ -445,6 +453,8 @@ class CustomFieldColumn(tables.Column): return mark_safe(', '.join( self._likify_item(obj) for obj in self.customfield.deserialize(value) )) + if self.customfield.type == CustomFieldTypeChoices.TYPE_LONGTEXT: + return Template(self.template_code).render(Context({"value": value})) if value is not None: obj = self.customfield.deserialize(value) return mark_safe(self._likify_item(obj)) diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index d55038c4d..deb0d8b90 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -181,7 +181,8 @@ class NetBoxTable(BaseTable): content_type = ContentType.objects.get_for_model(self._meta.model) custom_fields = CustomField.objects.filter(content_types=content_type) extra_columns.extend([ - (f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields + # (f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields + (f'cf_{cf.name}', columns.CustomFieldColumn(cf)) for cf in custom_fields ]) custom_links = CustomLink.objects.filter(content_type=content_type, enabled=True) extra_columns.extend([ From 6f09d94e2a99330ecd09e7d3ee0600fba8386716 Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Sat, 13 Aug 2022 13:56:51 +0200 Subject: [PATCH 15/26] remove commented line --- netbox/netbox/tables/tables.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index deb0d8b90..63aae1d19 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -181,7 +181,6 @@ class NetBoxTable(BaseTable): content_type = ContentType.objects.get_for_model(self._meta.model) custom_fields = CustomField.objects.filter(content_types=content_type) extra_columns.extend([ - # (f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields (f'cf_{cf.name}', columns.CustomFieldColumn(cf)) for cf in custom_fields ]) custom_links = CustomLink.objects.filter(content_type=content_type, enabled=True) From ac540b6183bd5bf8db57b1941de24aafc7b04f3c Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Sat, 13 Aug 2022 13:59:19 +0200 Subject: [PATCH 16/26] remove import --- netbox/netbox/tables/tables.py | 1 - 1 file changed, 1 deletion(-) diff --git a/netbox/netbox/tables/tables.py b/netbox/netbox/tables/tables.py index 63aae1d19..8c5fb039c 100644 --- a/netbox/netbox/tables/tables.py +++ b/netbox/netbox/tables/tables.py @@ -7,7 +7,6 @@ from django.db.models.fields.related import RelatedField from django_tables2.data import TableQuerysetData from extras.models import CustomField, CustomLink -from extras.choices import CustomFieldTypeChoices from netbox.tables import columns from utilities.paginator import EnhancedPaginator, get_paginate_count From 36491b13d86b26a0e75d84b8b5db64403f3fbe89 Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Sat, 13 Aug 2022 14:01:07 +0200 Subject: [PATCH 17/26] remove class definition --- netbox/netbox/tables/columns.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index 8b961219f..4918dd3b9 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -559,29 +559,4 @@ class MarkdownColumn(tables.TemplateColumn): ) def value(self, value): - return value - - -class CustomFieldMarkdownColumn(tables.TemplateColumn): - """ - Render a Markdown string in a longtext custom column. - """ - template_code = """ - {% if value %} - {{ value|markdown }} - {% else %} - — - {% endif %} - """ - - def __init__(self, customfield, *args, **kwargs): - self.customfield = customfield - kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}') - kwargs['template_code'] = self.template_code - if 'verbose_name' not in kwargs: - kwargs['verbose_name'] = customfield.label or customfield.name - - super().__init__(*args, **kwargs) - - def value(self, value): - return value + return value \ No newline at end of file From 15f4b1fd5daa5c8dd4338352d37049b47e4bf7de Mon Sep 17 00:00:00 2001 From: Christoph Schneider Date: Sat, 13 Aug 2022 14:02:26 +0200 Subject: [PATCH 18/26] add newline --- netbox/netbox/tables/columns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index 4918dd3b9..113c8416b 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -559,4 +559,4 @@ class MarkdownColumn(tables.TemplateColumn): ) def value(self, value): - return value \ No newline at end of file + return value From 30ab1e5a5e1f12c3e88b145c511741f75b5d460b Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 16 Aug 2022 09:14:19 -0400 Subject: [PATCH 19/26] Changelog for #8723, #9505, #9979 --- docs/release-notes/version-3.2.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index 824e99778..f515e4d35 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -5,12 +5,15 @@ ### Enhancements * [#8595](https://github.com/netbox-community/netbox/issues/8595) - Add PON interface types +* [#8723](https://github.com/netbox-community/netbox/issues/8723) - Enable bulk renaming of devices * [#9161](https://github.com/netbox-community/netbox/issues/9161) - Pretty print JSON custom field data when editing +* [#9505](https://github.com/netbox-community/netbox/issues/9505) - Display extra addressing details for IPv4 prefixes * [#9625](https://github.com/netbox-community/netbox/issues/9625) - Add phone & email details to contacts panel * [#9857](https://github.com/netbox-community/netbox/issues/9857) - Add clear button to quick search fields ### Bug Fixes +* [#9979](https://github.com/netbox-community/netbox/issues/9979) - Fix Markdown rendering for custom fields in table columns * [#9986](https://github.com/netbox-community/netbox/issues/9986) - Workaround for upstream timezone data bug --- From 0ef1bc8490dc2f6d6623a3b209406d57bc278efd Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 16 Aug 2022 09:49:51 -0400 Subject: [PATCH 20/26] Clean up bulk edit buttons --- .../templates/dcim/device/consoleports.html | 54 ++++++++++--------- .../dcim/device/consoleserverports.html | 54 ++++++++++--------- netbox/templates/dcim/device/devicebays.html | 44 +++++++-------- netbox/templates/dcim/device/frontports.html | 54 ++++++++++--------- netbox/templates/dcim/device/interfaces.html | 51 ++++++++++-------- netbox/templates/dcim/device/inventory.html | 44 +++++++-------- netbox/templates/dcim/device/modulebays.html | 44 +++++++-------- .../templates/dcim/device/poweroutlets.html | 54 ++++++++++--------- netbox/templates/dcim/device/powerports.html | 54 ++++++++++--------- netbox/templates/dcim/device/rearports.html | 54 ++++++++++--------- netbox/templates/dcim/device_list.html | 16 ++++-- .../virtualmachine/interfaces.html | 43 +++++++-------- 12 files changed, 311 insertions(+), 255 deletions(-) diff --git a/netbox/templates/dcim/device/consoleports.html b/netbox/templates/dcim/device/consoleports.html index afc306bd4..6f8b383c3 100644 --- a/netbox/templates/dcim/device/consoleports.html +++ b/netbox/templates/dcim/device/consoleports.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_consoleport %} - - - - {% endif %} - {% if perms.dcim.delete_consoleport %} - - {% endif %} -
- {% if perms.dcim.add_consoleport %} - +
+ {% if perms.dcim.change_consoleport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_consoleport %} + + {% endif %} + {% if perms.dcim.change_consoleport %} + + {% endif %} +
+
+ {% if perms.dcim.add_consoleport %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/consoleserverports.html b/netbox/templates/dcim/device/consoleserverports.html index 5f244cdc7..f246d4a82 100644 --- a/netbox/templates/dcim/device/consoleserverports.html +++ b/netbox/templates/dcim/device/consoleserverports.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_consoleserverport %} - - - - {% endif %} - {% if perms.dcim.delete_consoleserverport %} - - {% endif %} -
- {% if perms.dcim.add_consoleserverport %} - +
+ {% if perms.dcim.change_consoleserverport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_consoleserverport %} + + {% endif %} + {% if perms.dcim.change_consoleserverport %} + + {% endif %} +
+
+ {% if perms.dcim.add_consoleserverport %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/devicebays.html b/netbox/templates/dcim/device/devicebays.html index 5e33bdae0..d84408962 100644 --- a/netbox/templates/dcim/device/devicebays.html +++ b/netbox/templates/dcim/device/devicebays.html @@ -16,28 +16,30 @@
-
- {% if perms.dcim.change_devicebay %} - - - {% endif %} - {% if perms.dcim.delete_devicebay %} - - {% endif %} -
- {% if perms.dcim.add_devicebay %} - +
+ {% if perms.dcim.change_devicebay %} +
+ + +
{% endif %} + {% if perms.dcim.delete_devicebay %} + + {% endif %} +
+ {% if perms.dcim.add_devicebay %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/frontports.html b/netbox/templates/dcim/device/frontports.html index 0d0f9577c..513d02090 100644 --- a/netbox/templates/dcim/device/frontports.html +++ b/netbox/templates/dcim/device/frontports.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_frontport %} - - - - {% endif %} - {% if perms.dcim.delete_frontport %} - - {% endif %} -
- {% if perms.dcim.add_frontport %} - +
+ {% if perms.dcim.change_frontport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_frontport %} + + {% endif %} + {% if perms.dcim.change_frontport %} + + {% endif %} +
+
+ {% if perms.dcim.add_frontport %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/interfaces.html b/netbox/templates/dcim/device/interfaces.html index 94e38dbf3..2019d9135 100644 --- a/netbox/templates/dcim/device/interfaces.html +++ b/netbox/templates/dcim/device/interfaces.html @@ -9,7 +9,6 @@
{% csrf_token %} -
{% include 'htmx/table.html' %} @@ -19,29 +18,35 @@
{% if perms.dcim.change_interface %} - - - - {% endif %} - {% if perms.dcim.delete_interface %} - +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_interface %} + + {% endif %} + {% if perms.dcim.change_interface %} + + {% endif %} +
{% if perms.dcim.add_interface %}
diff --git a/netbox/templates/dcim/device/inventory.html b/netbox/templates/dcim/device/inventory.html index 18a0712f3..8b74acaae 100644 --- a/netbox/templates/dcim/device/inventory.html +++ b/netbox/templates/dcim/device/inventory.html @@ -16,28 +16,30 @@
-
- {% if perms.dcim.change_inventoryitem %} - - - {% endif %} - {% if perms.dcim.delete_inventoryitem %} - - {% endif %} -
- {% if perms.dcim.add_inventoryitem %} - +
+ {% if perms.dcim.change_inventoryitem %} +
+ + +
{% endif %} + {% if perms.dcim.delete_inventoryitem %} + + {% endif %} +
+ {% if perms.dcim.add_inventoryitem %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/modulebays.html b/netbox/templates/dcim/device/modulebays.html index fc1c9a60d..67b9d88d4 100644 --- a/netbox/templates/dcim/device/modulebays.html +++ b/netbox/templates/dcim/device/modulebays.html @@ -16,28 +16,30 @@
-
- {% if perms.dcim.change_modulebay %} - - - {% endif %} - {% if perms.dcim.delete_modulebay %} - - {% endif %} -
- {% if perms.dcim.add_modulebay %} - +
+ {% if perms.dcim.change_modulebay %} +
+ + +
{% endif %} + {% if perms.dcim.delete_modulebay %} + + {% endif %} +
+ {% if perms.dcim.add_modulebay %} + + {% endif %}
{% table_config_form table %} diff --git a/netbox/templates/dcim/device/poweroutlets.html b/netbox/templates/dcim/device/poweroutlets.html index d312fbbd0..61c2b61f4 100644 --- a/netbox/templates/dcim/device/poweroutlets.html +++ b/netbox/templates/dcim/device/poweroutlets.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_powerport %} - - - - {% endif %} - {% if perms.dcim.delete_poweroutlet %} - - {% endif %} -
- {% if perms.dcim.add_poweroutlet %} - +
+ {% if perms.dcim.change_powerport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_poweroutlet %} + + {% endif %} + {% if perms.dcim.change_powerport %} + + {% endif %} +
+
+ {% if perms.dcim.add_poweroutlet %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/powerports.html b/netbox/templates/dcim/device/powerports.html index cf71e81ba..cd8597e63 100644 --- a/netbox/templates/dcim/device/powerports.html +++ b/netbox/templates/dcim/device/powerports.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_powerport %} - - - - {% endif %} - {% if perms.dcim.delete_powerport %} - - {% endif %} -
- {% if perms.dcim.add_powerport %} - +
+ {% if perms.dcim.change_powerport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_powerport %} + + {% endif %} + {% if perms.dcim.change_powerport %} + + {% endif %} +
+
+ {% if perms.dcim.add_powerport %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device/rearports.html b/netbox/templates/dcim/device/rearports.html index 73341990f..b370de189 100644 --- a/netbox/templates/dcim/device/rearports.html +++ b/netbox/templates/dcim/device/rearports.html @@ -16,31 +16,37 @@
-
- {% if perms.dcim.change_rearport %} - - - - {% endif %} - {% if perms.dcim.delete_rearport %} - - {% endif %} -
- {% if perms.dcim.add_rearport %} - +
+ {% if perms.dcim.change_rearport %} +
+ + +
{% endif %} +
+ {% if perms.dcim.delete_rearport %} + + {% endif %} + {% if perms.dcim.change_rearport %} + + {% endif %} +
+
+ {% if perms.dcim.add_rearport %} + + {% endif %}
{% endblock %} diff --git a/netbox/templates/dcim/device_list.html b/netbox/templates/dcim/device_list.html index a576a1f9e..50af50525 100644 --- a/netbox/templates/dcim/device_list.html +++ b/netbox/templates/dcim/device_list.html @@ -1,10 +1,8 @@ {% extends 'generic/object_list.html' %} +{% load buttons %} {% block bulk_buttons %} {% if perms.dcim.change_device %} - {% endif %} - {{ block.super }} + {% if 'bulk_edit' in actions %} +
+ {% bulk_edit_button model query_params=request.GET %} + +
+ {% endif %} + {% if 'bulk_delete' in actions %} + {% bulk_delete_button model query_params=request.GET %} + {% endif %} {% endblock %} diff --git a/netbox/templates/virtualization/virtualmachine/interfaces.html b/netbox/templates/virtualization/virtualmachine/interfaces.html index e3ffb84d4..eff98cdd6 100644 --- a/netbox/templates/virtualization/virtualmachine/interfaces.html +++ b/netbox/templates/virtualization/virtualmachine/interfaces.html @@ -15,27 +15,28 @@
- {% if perms.virtualization.change_vminterface %} - - - {% endif %} - {% if perms.virtualization.delete_vminterface %} - - {% endif %} - {% if perms.virtualization.add_vminterface %} - - {% endif %} -
+ {% if perms.virtualization.change_vminterface %} +
+ + +
+ {% endif %} + {% if perms.virtualization.delete_vminterface %} + + {% endif %} + {% if perms.virtualization.add_vminterface %} + + {% endif %}
{% endblock content %} From dedee0f9d9d3abded2a6665aea43283be7cc1a8b Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 16 Aug 2022 09:53:13 -0400 Subject: [PATCH 21/26] #9979: Fix fallback to default value --- netbox/netbox/tables/columns.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index 113c8416b..6ab50d4c2 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -14,6 +14,7 @@ from django_tables2.columns import library from django_tables2.utils import Accessor from extras.choices import CustomFieldTypeChoices +from utilities.templatetags.builtins.filters import render_markdown from utilities.utils import content_type_identifier, content_type_name, get_viewname __all__ = ( @@ -418,14 +419,6 @@ class CustomFieldColumn(tables.Column): """ Display custom fields in the appropriate format. """ - template_code = """ - {% if value %} - {{ value|markdown }} - {% else %} - — - {% endif %} - """ - def __init__(self, customfield, *args, **kwargs): self.customfield = customfield kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}') @@ -435,7 +428,7 @@ class CustomFieldColumn(tables.Column): super().__init__(*args, **kwargs) @staticmethod - def _likify_item(item): + def _linkify_item(item): if hasattr(item, 'get_absolute_url'): return f'{escape(item)}' return escape(item) @@ -451,13 +444,13 @@ class CustomFieldColumn(tables.Column): return ', '.join(v for v in value) if self.customfield.type == CustomFieldTypeChoices.TYPE_MULTIOBJECT: return mark_safe(', '.join( - self._likify_item(obj) for obj in self.customfield.deserialize(value) + self._linkify_item(obj) for obj in self.customfield.deserialize(value) )) - if self.customfield.type == CustomFieldTypeChoices.TYPE_LONGTEXT: - return Template(self.template_code).render(Context({"value": value})) + if self.customfield.type == CustomFieldTypeChoices.TYPE_LONGTEXT and value: + return render_markdown(value) if value is not None: obj = self.customfield.deserialize(value) - return mark_safe(self._likify_item(obj)) + return mark_safe(self._linkify_item(obj)) return self.default def value(self, value): From 6d328a82e9dac52821bba08841caa2e1188c310c Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 16 Aug 2022 10:04:47 -0400 Subject: [PATCH 22/26] Cleanup for #9505 --- netbox/templates/ipam/prefix.html | 95 +++++++++++++------------------ 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/netbox/templates/ipam/prefix.html b/netbox/templates/ipam/prefix.html index ed2c3339b..b15aa60bb 100644 --- a/netbox/templates/ipam/prefix.html +++ b/netbox/templates/ipam/prefix.html @@ -144,15 +144,14 @@ + {% if object.prefix.version == 4 %} + + {% endif %} - {% if object.prefix.version == 4 %} - - {% endif %} {% include 'inc/panels/custom_fields.html' %} {% include 'inc/panels/tags.html' %} @@ -168,54 +167,40 @@ {% plugin_full_width_page object %} -{% if object.prefix.version == 4 %} -