Skip to content

Commit

Permalink
Add bulk views (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps authored Sep 18, 2024
2 parents 577a94b + 65cd0d8 commit 0e432f5
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
14 changes: 12 additions & 2 deletions netbox_lifecycle/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@
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/<int:pk>', views.HardwareLifecycleView.as_view(), name='hardwarelifecycle'),
path('lifecycle/<int:pk>/edit', views.HardwareLifecycleEditView.as_view(), name='hardwarelifecycle_edit'),
path('lifecycle/<int:pk>/delete', views.HardwareLifecycleDeleteView.as_view(), name='hardwarelifecycle_delete'),
path('lifecycle/<int:pk>/changelog', ObjectChangeLogView.as_view(), name='hardwarelifecycle_changelog', kwargs={'model': HardwareLifecycle}),

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/<int:pk>', views.VendorView.as_view(), name='vendor'),
path('vendors/<int:pk>/edit', views.VendorEditView.as_view(), name='vendor_edit'),
path('vendors/<int:pk>/delete', views.VendorDeleteView.as_view(), name='vendor_delete'),
path('vendors/<int:pk>/changelog', ObjectChangeLogView.as_view(), name='vendor_changelog', kwargs={'model': SupportContract}),

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/<int:pk>', views.SupportContractView.as_view(), name='supportcontract'),
path('contracts/<int:pk>/devices', views.SupportContractAssignmentView.as_view(), name='supportcontract_assignments'),
path('contracts/<int:pk>/edit', views.SupportContractEditView.as_view(), name='supportcontract_edit'),
Expand All @@ -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/<int:pk>', views.LicenseView.as_view(), name='license'),
path('license/<int:pk>/assignments', views.LicenseAssignmentView.as_view(), name='license_assignments'),
path('license/<int:pk>/edit', views.LicenseEditView.as_view(), name='license_edit'),
Expand All @@ -46,16 +54,18 @@

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/<int:pk>', views.SupportSKUView.as_view(), name='supportsku'),
path('sku/<int:pk>/edit', views.SupportSKUEditView.as_view(), name='supportsku_edit'),
path('sku/<int:pk>/delete', views.SupportSKUDeleteView.as_view(), name='supportsku_delete'),
path('sku/<int:pk>/changelog', ObjectChangeLogView.as_view(), name='supportsku_changelog', kwargs={'model': SupportSKU}),

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/<int:pk>/edit', views.LicenseAssignmentEditView.as_view(), name='licenseassignment_edit'),
path('license-assignment/<int:pk>/delete', views.LicenseAssignmentDeleteView.as_view(), name='licenseassignment_delete'),
path('license-assignment/<int:pk>/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/<int:pk>/edit', views.LicenseAssignmentEditView.as_view(), name='licenseassignment_edit'),
]
51 changes: 51 additions & 0 deletions netbox_lifecycle/views/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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()
Expand 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')
Expand Down Expand Up @@ -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'
Expand Down
21 changes: 20 additions & 1 deletion netbox_lifecycle/views/hardware.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +12,9 @@
'HardwareLifecycleListView',
'HardwareLifecycleView',
'HardwareLifecycleEditView',
'HardwareLifecycleBulkEditView',
'HardwareLifecycleDeleteView',
'HardwareLifecycleBulkDeleteView',
)


Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions netbox_lifecycle/views/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
'LicenseListView',
'LicenseView',
'LicenseEditView',
'LicenseBulkEditView',
'LicenseDeleteView',
'LicenseBulkDeleteView',
'LicenseAssignmentView',
'LicenseAssignmentListView',
'LicenseAssignmentEditView',
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 0e432f5

Please sign in to comment.