Partially implements #4 Based on @erichester76's https://github.com/ICTU/netbox_slm/pull/44 Signed-off-by: wkoot <3715211+wkoot@users.noreply.github.com> Co-authored-by: Eric Hester <eric.hester@umbrella.tech>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from netbox.views import generic
|
|
from netbox_slm import filtersets, forms, tables
|
|
from netbox_slm.models import SoftwareProduct
|
|
|
|
|
|
class SoftwareProductListView(generic.ObjectListView):
|
|
"""View for listing all existing SoftwareProducts."""
|
|
|
|
queryset = SoftwareProduct.objects.all()
|
|
filterset = filtersets.SoftwareProductFilterSet
|
|
filterset_form = forms.SoftwareProductFilterForm
|
|
table = tables.SoftwareProductTable
|
|
|
|
|
|
class SoftwareProductView(generic.ObjectView):
|
|
"""Display SoftwareProduct details"""
|
|
|
|
queryset = SoftwareProduct.objects.all()
|
|
|
|
def get_extra_context(self, request, instance):
|
|
versions = instance.softwareproductversion_set.all()
|
|
return {"versions": versions}
|
|
|
|
|
|
class SoftwareProductEditView(generic.ObjectEditView):
|
|
"""View for editing and creating a SoftwareProduct instance."""
|
|
|
|
queryset = SoftwareProduct.objects.all()
|
|
form = forms.SoftwareProductForm
|
|
|
|
|
|
class SoftwareProductDeleteView(generic.ObjectDeleteView):
|
|
"""View for deleting a SoftwareProduct instance"""
|
|
|
|
queryset = SoftwareProduct.objects.all()
|
|
|
|
|
|
class SoftwareProductBulkDeleteView(generic.BulkDeleteView):
|
|
queryset = SoftwareProduct.objects.all()
|
|
table = tables.SoftwareProductTable
|
|
|
|
|
|
class SoftwareProductBulkImportView(generic.BulkImportView):
|
|
queryset = SoftwareProduct.objects.all()
|
|
table = tables.SoftwareProductTable
|
|
model_form = forms.SoftwareProductBulkImportForm
|