From 1547f1993b1ff957a40711a2cc48f55fcd65439b Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Wed, 18 Sep 2024 10:08:34 -0500 Subject: [PATCH] Add bulk views --- netbox_lifecycle/urls.py | 14 ++++++-- netbox_lifecycle/views/contract.py | 51 ++++++++++++++++++++++++++++++ netbox_lifecycle/views/hardware.py | 21 +++++++++++- netbox_lifecycle/views/license.py | 17 ++++++++++ 4 files changed, 100 insertions(+), 3 deletions(-) diff --git a/netbox_lifecycle/urls.py b/netbox_lifecycle/urls.py index 7b03471..7939aa9 100644 --- a/netbox_lifecycle/urls.py +++ b/netbox_lifecycle/urls.py @@ -8,6 +8,8 @@ urlpatterns = [ path('lifecycle/', views.HardwareLifecycleListView.as_view(), name='hardwarelifecycle_list'), path('lifecycle/add', views.HardwareLifecycleEditView.as_view(), name='hardwarelifecycle_add'), + path('lifecycle/edit', views.HardwareLifecycleBulkEditView.as_view(), name='hardwarelifecycle_bulk_edit'), + path('lifecycle/delete', views.HardwareLifecycleBulkDeleteView.as_view(), name='hardwarelifecycle_bulk_delete'), path('lifecycle/', views.HardwareLifecycleView.as_view(), name='hardwarelifecycle'), path('lifecycle//edit', views.HardwareLifecycleEditView.as_view(), name='hardwarelifecycle_edit'), path('lifecycle//delete', views.HardwareLifecycleDeleteView.as_view(), name='hardwarelifecycle_delete'), @@ -15,6 +17,8 @@ path('vendors/', views.VendorListView.as_view(), name='vendor_list'), path('vendors/add', views.VendorEditView.as_view(), name='vendor_add'), + path('vendors/edit', views.VendorBulkEditView.as_view(), name='vendor_bulk_edit'), + path('vendors/delete', views.VendorBulkDeleteView.as_view(), name='vendor_bulk_delete'), path('vendors/', views.VendorView.as_view(), name='vendor'), path('vendors//edit', views.VendorEditView.as_view(), name='vendor_edit'), path('vendors//delete', views.VendorDeleteView.as_view(), name='vendor_delete'), @@ -22,6 +26,8 @@ path('contracts/', views.SupportContractListView.as_view(), name='supportcontract_list'), path('contracts/add', views.SupportContractEditView.as_view(), name='supportcontract_add'), + path('contracts/edit', views.SupportContractBulkEditView.as_view(), name='supportcontract_bulk_edit'), + path('contracts/delete', views.SupportContractBulkDeleteView.as_view(), name='supportcontract_bulk_delete'), path('contracts/', views.SupportContractView.as_view(), name='supportcontract'), path('contracts//devices', views.SupportContractAssignmentView.as_view(), name='supportcontract_assignments'), path('contracts//edit', views.SupportContractEditView.as_view(), name='supportcontract_edit'), @@ -38,6 +44,8 @@ path('license/', views.LicenseListView.as_view(), name='license_list'), path('license/add', views.LicenseEditView.as_view(), name='license_add'), + path('license/edit', views.LicenseBulkEditView.as_view(), name='license_bulk_edit'), + path('license/delete', views.LicenseBulkDeleteView.as_view(), name='license_bulk_delete'), path('license/', views.LicenseView.as_view(), name='license'), path('license//assignments', views.LicenseAssignmentView.as_view(), name='license_assignments'), path('license//edit', views.LicenseEditView.as_view(), name='license_edit'), @@ -46,6 +54,8 @@ path('sku/', views.SupportSKUListView.as_view(), name='supportsku_list'), path('sku/add', views.SupportSKUEditView.as_view(), name='supportsku_add'), + path('sku/edit', views.SupportSKUBulkEditView.as_view(), name='supportsku_bulk_edit'), + path('sku/delete', views.SupportSKUBulkDeleteView.as_view(), name='supportsku_bulk_delete'), path('sku/', views.SupportSKUView.as_view(), name='supportsku'), path('sku//edit', views.SupportSKUEditView.as_view(), name='supportsku_edit'), path('sku//delete', views.SupportSKUDeleteView.as_view(), name='supportsku_delete'), @@ -53,9 +63,9 @@ path('license-assignment/', views.LicenseAssignmentListView.as_view(), name='licenseassignment_list'), path('license-assignment/add', views.LicenseAssignmentEditView.as_view(), name='licenseassignment_add'), + path('license-assignment/edit', views.LicenseAssignmentBulkEditView.as_view(), name='licenseassignment_edit'), + path('license-assignment/delete/', views.LicenseAssignmentBulkDeleteView.as_view(), name='licenseassignment_bulk_delete'), path('license-assignment//edit', views.LicenseAssignmentEditView.as_view(), name='licenseassignment_edit'), path('license-assignment//delete', views.LicenseAssignmentDeleteView.as_view(), name='licenseassignment_delete'), path('license-assignment//changelog', ObjectChangeLogView.as_view(), name='licenseassignment_changelog', kwargs={'model': LicenseAssignment}), - path('license-assignment/delete/', views.LicenseAssignmentBulkDeleteView.as_view(), name='licenseassignment_bulk_delete'), - path('license-assignment//edit', views.LicenseAssignmentEditView.as_view(), name='licenseassignment_edit'), ] diff --git a/netbox_lifecycle/views/contract.py b/netbox_lifecycle/views/contract.py index 8bf7934..588abc8 100644 --- a/netbox_lifecycle/views/contract.py +++ b/netbox_lifecycle/views/contract.py @@ -15,16 +15,22 @@ 'VendorListView', 'VendorView', 'VendorEditView', + 'VendorBulkEditView', 'VendorDeleteView', + 'VendorBulkDeleteView', 'SupportSKUListView', 'SupportSKUView', 'SupportSKUEditView', + 'SupportSKUBulkEditView', 'SupportSKUDeleteView', + 'SupportSKUBulkDeleteView', 'SupportContractListView', 'SupportContractView', 'SupportContractAssignmentView', 'SupportContractEditView', + 'SupportContractBulkEditView', 'SupportContractDeleteView', + 'SupportContractBulkDeleteView', 'SupportContractAssignmentListView', 'SupportContractAssignmentEditView', 'SupportContractAssignmentDeleteView', @@ -52,11 +58,26 @@ class VendorEditView(ObjectEditView): form = VendorForm +@register_model_view(Vendor, 'bulk_edit') +class VendorBulkEditView(BulkEditView): + queryset = Vendor.objects.all() + filterset = VendorFilterSet + table = VendorTable + form = VendorForm + + @register_model_view(Vendor, 'delete') class VendorDeleteView(ObjectDeleteView): queryset = Vendor.objects.all() +@register_model_view(Vendor, 'bulk_delete') +class VendorBulkDeleteView(BulkDeleteView): + queryset = Vendor.objects.all() + filterset = VendorFilterSet + table = VendorTable + + @register_model_view(SupportSKU, name='list') class SupportSKUListView(ObjectListView): queryset = SupportSKU.objects.all() @@ -76,9 +97,24 @@ class SupportSKUEditView(ObjectEditView): form = SupportSKUForm +@register_model_view(SupportSKU, 'bulk_edit') +class SupportSKUBulkEditView(BulkEditView): + queryset = SupportSKU.objects.all() + filterset = SupportSKUFilterSet + table = SupportSKUTable + form = SupportSKUForm + + @register_model_view(SupportSKU, 'delete') class SupportSKUDeleteView(ObjectDeleteView): queryset = SupportSKU.objects.all() + filterset = SupportSKUFilterSet + table = SupportSKUTable + + +@register_model_view(SupportSKU, 'bulk_delete') +class SupportSKUBulkDeleteView(BulkDeleteView): + queryset = SupportSKU.objects.all() @register_model_view(SupportContract, name='list') @@ -121,11 +157,26 @@ class SupportContractEditView(ObjectEditView): form = SupportContractForm +@register_model_view(SupportContract, 'bulk_edit') +class SupportContractBulkEditView(BulkEditView): + queryset = SupportContract.objects.all() + filterset = SupportContractFilterSet + table = SupportContractTable + form = SupportContractForm + + @register_model_view(SupportContract, 'delete') class SupportContractDeleteView(ObjectDeleteView): queryset = SupportContract.objects.all() +@register_model_view(SupportContract, 'bulk_delete') +class SupportContractBulkDeleteView(BulkDeleteView): + queryset = SupportContract.objects.all() + filterset = SupportContractFilterSet + table = SupportContractTable + + @register_model_view(SupportContractAssignment, 'edit') class SupportContractAssignmentEditView(ObjectEditView): template_name = 'netbox_lifecycle/supportcontractassignment_edit.html' diff --git a/netbox_lifecycle/views/hardware.py b/netbox_lifecycle/views/hardware.py index 61a037a..5be329f 100644 --- a/netbox_lifecycle/views/hardware.py +++ b/netbox_lifecycle/views/hardware.py @@ -1,4 +1,5 @@ -from netbox.views.generic import ObjectListView, ObjectEditView, ObjectDeleteView, ObjectView +from netbox.views.generic import (ObjectListView, ObjectEditView, ObjectDeleteView, ObjectView, BulkEditView, + BulkDeleteView) from netbox_lifecycle.filtersets import HardwareLifecycleFilterSet from netbox_lifecycle.forms import HardwareLifecycleFilterForm from netbox_lifecycle.forms.model_forms import HardwareLifecycleForm @@ -11,7 +12,9 @@ 'HardwareLifecycleListView', 'HardwareLifecycleView', 'HardwareLifecycleEditView', + 'HardwareLifecycleBulkEditView', 'HardwareLifecycleDeleteView', + 'HardwareLifecycleBulkDeleteView', ) @@ -40,6 +43,22 @@ class HardwareLifecycleEditView(ObjectEditView): form = HardwareLifecycleForm +@register_model_view(HardwareLifecycle, 'bulk_edit') +class HardwareLifecycleBulkEditView(BulkEditView): + template_name = 'netbox_lifecycle/hardwarelifecycle_edit.html' + queryset = HardwareLifecycle.objects.all() + filterset = HardwareLifecycleFilterSet + table = HardwareLifecycleTable + form = HardwareLifecycleForm + + @register_model_view(HardwareLifecycle, 'delete') class HardwareLifecycleDeleteView(ObjectDeleteView): queryset = HardwareLifecycle.objects.all() + + +@register_model_view(HardwareLifecycle, 'bulk_delete') +class HardwareLifecycleBulkDeleteView(BulkDeleteView): + queryset = HardwareLifecycle.objects.all() + filterset = HardwareLifecycleFilterSet + table = HardwareLifecycleTable diff --git a/netbox_lifecycle/views/license.py b/netbox_lifecycle/views/license.py index 12f25a3..489aa1a 100644 --- a/netbox_lifecycle/views/license.py +++ b/netbox_lifecycle/views/license.py @@ -12,7 +12,9 @@ 'LicenseListView', 'LicenseView', 'LicenseEditView', + 'LicenseBulkEditView', 'LicenseDeleteView', + 'LicenseBulkDeleteView', 'LicenseAssignmentView', 'LicenseAssignmentListView', 'LicenseAssignmentEditView', @@ -41,11 +43,26 @@ class LicenseEditView(ObjectEditView): form = LicenseForm +@register_model_view(License, 'bulk_edit') +class LicenseBulkEditView(BulkEditView): + queryset = License.objects.all() + filterset = LicenseFilterSet + table = LicenseTable + form = LicenseForm + + @register_model_view(License, 'delete') class LicenseDeleteView(ObjectDeleteView): queryset = License.objects.all() +@register_model_view(License, 'bulk_delete') +class LicenseBulkDeleteView(BulkDeleteView): + queryset = License.objects.all() + filterset = LicenseFilterSet + table = LicenseTable + + @register_model_view(License, 'assignments') class LicenseAssignmentView(ObjectChildrenView): template_name = 'netbox_lifecycle/license/assignments.html'