Add bulk import and bulk edit (#60)

Closes #4

Signed-off-by: wkoot <3715211+wkoot@users.noreply.github.com>
This commit is contained in:
wkoot
2025-02-19 23:07:47 +01:00
parent 410b8f6617
commit 4bd02ab6f9
14 changed files with 275 additions and 199 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
### Added ### Added
* Toggle to show plugin as top level menu item (#42) * Toggle to show plugin as top level menu item (#42)
* Bulk import except `LaxURLFields` (#4) * Bulk import and bulk edit (#4)
* Changelog with backdated changes (#51) * Changelog with backdated changes (#51)
* List filtering (#54) * List filtering (#54)
+14 -2
View File
@@ -1,12 +1,24 @@
from .software_license import SoftwareLicenseForm, SoftwareLicenseFilterForm, SoftwareLicenseBulkImportForm from .software_license import (
from .software_product import SoftwareProductForm, SoftwareProductFilterForm, SoftwareProductBulkImportForm SoftwareLicenseForm,
SoftwareLicenseFilterForm,
SoftwareLicenseBulkImportForm,
SoftwareLicenseBulkEditForm,
)
from .software_product import (
SoftwareProductForm,
SoftwareProductFilterForm,
SoftwareProductBulkImportForm,
SoftwareProductBulkEditForm,
)
from .software_product_installation import ( from .software_product_installation import (
SoftwareProductInstallationForm, SoftwareProductInstallationForm,
SoftwareProductInstallationFilterForm, SoftwareProductInstallationFilterForm,
SoftwareProductInstallationBulkImportForm, SoftwareProductInstallationBulkImportForm,
SoftwareProductInstallationBulkEditForm,
) )
from .software_product_version import ( from .software_product_version import (
SoftwareProductVersionForm, SoftwareProductVersionForm,
SoftwareProductVersionFilterForm, SoftwareProductVersionFilterForm,
SoftwareProductVersionBulkImportForm, SoftwareProductVersionBulkImportForm,
SoftwareProductVersionBulkEditForm,
) )
+69 -14
View File
@@ -1,7 +1,7 @@
from django.forms import CharField, DateField, ChoiceField from django.forms import CharField, DateField, ChoiceField, IntegerField, NullBooleanField
from django.urls import reverse_lazy from django.urls import reverse_lazy
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm, NetBoxModelBulkEditForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
from utilities.forms.constants import BOOLEAN_WITH_BLANK_CHOICES from utilities.forms.constants import BOOLEAN_WITH_BLANK_CHOICES
from utilities.forms.fields import ( from utilities.forms.fields import (
@@ -16,25 +16,22 @@ from utilities.forms.widgets import APISelect, DatePicker
class SoftwareLicenseForm(NetBoxModelForm): class SoftwareLicenseForm(NetBoxModelForm):
"""Form for creating a new SoftwareLicense object."""
comments = CommentField() comments = CommentField()
stored_location_url = LaxURLField(required=False) stored_location_url = LaxURLField(required=False)
start_date = DateField(required=False, widget=DatePicker())
expiration_date = DateField(required=False, widget=DatePicker())
software_product = DynamicModelChoiceField( software_product = DynamicModelChoiceField(
queryset=SoftwareProduct.objects.all(), queryset=SoftwareProduct.objects.all(),
required=True, required=True,
label="Software Product", label="Software Product",
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}),
) )
version = DynamicModelChoiceField( version = DynamicModelChoiceField(
queryset=SoftwareProductVersion.objects.all(), queryset=SoftwareProductVersion.objects.all(),
required=False, required=False,
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}), widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}),
query_params={ query_params=dict(software_product="$software_product"),
"software_product": "$software_product",
},
) )
installation = DynamicModelChoiceField( installation = DynamicModelChoiceField(
queryset=SoftwareProductInstallation.objects.all(), queryset=SoftwareProductInstallation.objects.all(),
@@ -42,12 +39,8 @@ class SoftwareLicenseForm(NetBoxModelForm):
widget=APISelect( widget=APISelect(
attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductinstallation-list")} attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductinstallation-list")}
), ),
query_params={ query_params=dict(software_product="$software_product"),
"software_product": "$software_product",
},
) )
start_date = DateField(required=False, widget=DatePicker())
expiration_date = DateField(required=False, widget=DatePicker())
class Meta: class Meta:
model = SoftwareLicense model = SoftwareLicense
@@ -112,6 +105,8 @@ class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
class SoftwareLicenseBulkImportForm(NetBoxModelImportForm): class SoftwareLicenseBulkImportForm(NetBoxModelImportForm):
support = NullBooleanField(required=False, help_text="Support (values other than 'True' and 'False' are ignored)")
class Meta: class Meta:
model = SoftwareLicense model = SoftwareLicense
fields = ( fields = (
@@ -119,6 +114,7 @@ class SoftwareLicenseBulkImportForm(NetBoxModelImportForm):
"description", "description",
"software_product", "software_product",
"type", "type",
"stored_location",
"start_date", "start_date",
"expiration_date", "expiration_date",
"support", "support",
@@ -126,5 +122,64 @@ class SoftwareLicenseBulkImportForm(NetBoxModelImportForm):
"version", "version",
"installation", "installation",
"tags", "tags",
"comments",
) )
class SoftwareLicenseBulkEditForm(NetBoxModelBulkEditForm):
model = SoftwareLicense
fieldsets = (
FieldSet(
"type",
"stored_location",
"stored_location_url",
"start_date",
"expiration_date",
"support",
"license_amount",
"software_product",
"version",
"installation",
),
)
nullable_fields = (
"type",
"stored_location",
"stored_location_url",
"start_date",
"expiration_date",
"support",
"license_amount",
"version",
"installation",
)
tag = TagFilterField(model)
comments = CommentField()
type = CharField(required=False)
stored_location = CharField(required=False)
stored_location_url = LaxURLField(required=False)
start_date = DateField(required=False, widget=DatePicker())
expiration_date = DateField(required=False, widget=DatePicker())
support = ChoiceField(required=False, choices=BOOLEAN_WITH_BLANK_CHOICES)
license_amount = IntegerField(required=False, min_value=0)
software_product = DynamicModelChoiceField(
queryset=SoftwareProduct.objects.all(),
required=False,
label="Software Product",
)
version = DynamicModelChoiceField(
queryset=SoftwareProductVersion.objects.all(),
required=False,
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}),
query_params=dict(software_product="$software_product"),
)
installation = DynamicModelChoiceField(
queryset=SoftwareProductInstallation.objects.all(),
required=False,
widget=APISelect(
attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductinstallation-list")}
),
query_params=dict(software_product="$software_product"),
)
+15 -4
View File
@@ -1,7 +1,7 @@
from django.forms import CharField from django.forms import CharField
from dcim.models import Manufacturer from dcim.models import Manufacturer
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm, NetBoxModelBulkEditForm
from netbox_slm.models import SoftwareProduct from netbox_slm.models import SoftwareProduct
from utilities.forms.fields import ( from utilities.forms.fields import (
CommentField, CommentField,
@@ -13,8 +13,6 @@ from utilities.forms.rendering import FieldSet
class SoftwareProductForm(NetBoxModelForm): class SoftwareProductForm(NetBoxModelForm):
"""Form for creating a new SoftwareProduct object."""
comments = CommentField() comments = CommentField()
manufacturer = DynamicModelChoiceField( manufacturer = DynamicModelChoiceField(
@@ -60,5 +58,18 @@ class SoftwareProductBulkImportForm(NetBoxModelImportForm):
"description", "description",
"manufacturer", "manufacturer",
"tags", "tags",
"comments",
) )
class SoftwareProductBulkEditForm(NetBoxModelBulkEditForm):
model = SoftwareProduct
fieldsets = (FieldSet("manufacturer"),)
nullable_fields = ("manufacturer", "comments")
tag = TagFilterField(model)
comments = CommentField()
manufacturer = DynamicModelChoiceField(
queryset=Manufacturer.objects.all(),
required=False,
)
@@ -2,7 +2,7 @@ from django.forms import ValidationError
from django.urls import reverse_lazy from django.urls import reverse_lazy
from dcim.models import Device from dcim.models import Device
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm, NetBoxModelBulkEditForm
from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import ( from utilities.forms.fields import (
CommentField, CommentField,
@@ -16,8 +16,6 @@ from virtualization.models import VirtualMachine, Cluster
class SoftwareProductInstallationForm(NetBoxModelForm): class SoftwareProductInstallationForm(NetBoxModelForm):
"""Form for creating a new SoftwareProductInstallation object."""
comments = CommentField() comments = CommentField()
device = DynamicModelChoiceField(queryset=Device.objects.all(), required=False) device = DynamicModelChoiceField(queryset=Device.objects.all(), required=False)
@@ -31,15 +29,12 @@ class SoftwareProductInstallationForm(NetBoxModelForm):
queryset=SoftwareProduct.objects.all(), queryset=SoftwareProduct.objects.all(),
required=True, required=True,
label="Software Product", label="Software Product",
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}),
) )
version = DynamicModelChoiceField( version = DynamicModelChoiceField(
queryset=SoftwareProductVersion.objects.all(), queryset=SoftwareProductVersion.objects.all(),
required=True, required=True,
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}), widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}),
query_params={ query_params=dict(software_product="$software_product"),
"software_product": "$software_product",
},
) )
class Meta: class Meta:
@@ -112,5 +107,32 @@ class SoftwareProductInstallationBulkImportForm(NetBoxModelImportForm):
"software_product", "software_product",
"version", "version",
"tags", "tags",
"comments",
) )
class SoftwareProductInstallationBulkEditForm(NetBoxModelBulkEditForm):
model = SoftwareProductInstallation
fieldsets = (FieldSet("device", "virtualmachine", "cluster", "software_product", "version"),)
nullable_fields = ("device", "virtualmachine", "cluster", "comments")
tag = TagFilterField(model)
comments = CommentField()
device = DynamicModelChoiceField(queryset=Device.objects.all(), required=False)
virtualmachine = DynamicModelChoiceField(
queryset=VirtualMachine.objects.all(),
required=False,
label="Virtual Machine",
)
cluster = DynamicModelChoiceField(queryset=Cluster.objects.all(), required=False)
software_product = DynamicModelChoiceField(
queryset=SoftwareProduct.objects.all(),
required=False,
label="Software Product",
)
version = DynamicModelChoiceField(
queryset=SoftwareProductVersion.objects.all(),
required=False,
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductversion-list")}),
query_params=dict(software_product="$software_product"),
)
+38 -4
View File
@@ -2,7 +2,7 @@ from django.forms import DateField, CharField, MultipleChoiceField
from django.urls import reverse_lazy from django.urls import reverse_lazy
from dcim.models import Manufacturer from dcim.models import Manufacturer
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm, NetBoxModelBulkEditForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareReleaseTypes from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareReleaseTypes
from utilities.forms.fields import ( from utilities.forms.fields import (
CommentField, CommentField,
@@ -15,8 +15,6 @@ from utilities.forms.widgets import APISelect, DatePicker
class SoftwareProductVersionForm(NetBoxModelForm): class SoftwareProductVersionForm(NetBoxModelForm):
"""Form for creating a new SoftwareProductVersion object."""
comments = CommentField() comments = CommentField()
release_date = DateField(required=False, widget=DatePicker()) release_date = DateField(required=False, widget=DatePicker())
@@ -76,6 +74,8 @@ class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm): class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm):
release_type = CharField(help_text=f"Release type (possible values: {SoftwareReleaseTypes.values})")
class Meta: class Meta:
model = SoftwareProductVersion model = SoftwareProductVersion
fields = ( fields = (
@@ -88,5 +88,39 @@ class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm):
"file_checksum", "file_checksum",
"release_type", "release_type",
"tags", "tags",
"comments",
) )
class SoftwareProductVersionBulkEditForm(NetBoxModelBulkEditForm):
model = SoftwareProductVersion
fieldsets = (
FieldSet(
"release_date",
"documentation_url",
"end_of_support",
"filename",
"file_checksum",
"file_link",
"release_type",
"software_product",
),
)
nullable_fields = ("release_date", "documentation_url", "end_of_support", "filename", "file_checksum", "file_link")
tag = TagFilterField(model)
comments = CommentField()
release_date = DateField(required=False, widget=DatePicker())
documentation_url = CharField(required=False)
end_of_support = DateField(required=False, widget=DatePicker())
filename = CharField(required=False)
file_checksum = CharField(required=False)
file_link = CharField(required=False)
release_type = MultipleChoiceField(required=False, choices=SoftwareReleaseTypes.choices)
software_product = DynamicModelChoiceField(
queryset=SoftwareProduct.objects.all(),
required=False,
label="Software Product",
)
+4 -4
View File
@@ -16,7 +16,7 @@ slm_items = (
permissions=["netbox_slm.add_softwareproduct"], permissions=["netbox_slm.add_softwareproduct"],
), ),
PluginMenuButton( PluginMenuButton(
"plugins:netbox_slm:softwareproduct_import", "plugins:netbox_slm:softwareproduct_bulk_import",
"Import", "Import",
"mdi mdi-upload", "mdi mdi-upload",
permissions=["netbox_slm.import_softwareproduct"], permissions=["netbox_slm.import_softwareproduct"],
@@ -35,7 +35,7 @@ slm_items = (
permissions=["netbox_slm.add_softwareproductversion"], permissions=["netbox_slm.add_softwareproductversion"],
), ),
PluginMenuButton( PluginMenuButton(
"plugins:netbox_slm:softwareproductversion_import", "plugins:netbox_slm:softwareproductversion_bulk_import",
"Import", "Import",
"mdi mdi-upload", "mdi mdi-upload",
permissions=["netbox_slm.import_softwareproductversion"], permissions=["netbox_slm.import_softwareproductversion"],
@@ -54,7 +54,7 @@ slm_items = (
permissions=["netbox_slm.add_softwareproductinstallation"], permissions=["netbox_slm.add_softwareproductinstallation"],
), ),
PluginMenuButton( PluginMenuButton(
"plugins:netbox_slm:softwareproductinstallation_import", "plugins:netbox_slm:softwareproductinstallation_bulk_import",
"Import", "Import",
"mdi mdi-upload", "mdi mdi-upload",
permissions=["netbox_slm.import_softwareproductinstallation"], permissions=["netbox_slm.import_softwareproductinstallation"],
@@ -73,7 +73,7 @@ slm_items = (
permissions=["netbox_slm.add_softwarelicense"], permissions=["netbox_slm.add_softwarelicense"],
), ),
PluginMenuButton( PluginMenuButton(
"plugins:netbox_slm:softwarelicense_import", "plugins:netbox_slm:softwarelicense_bulk_import",
"Import", "Import",
"mdi mdi-upload", "mdi mdi-upload",
permissions=["netbox_slm.import_softwarelicense"], permissions=["netbox_slm.import_softwarelicense"],
+1
View File
@@ -167,6 +167,7 @@ class SoftwareLicenseTable(NetBoxTable):
default_columns = ( default_columns = (
"pk", "pk",
"name", "name",
"type",
"manufacturer", "manufacturer",
"software_product", "software_product",
"installation", "installation",
@@ -20,6 +20,10 @@
<th scope="row">Description</th> <th scope="row">Description</th>
<td>{{ object.description }}</td> <td>{{ object.description }}</td>
</tr> </tr>
<tr>
<th scope="row">Type</th>
<td>{{ object.type }}</td>
</tr>
<tr> <tr>
<th scope="row">Software Product</th> <th scope="row">Software Product</th>
<td>{{ object.software_product|linkify }}</td> <td>{{ object.software_product|linkify }}</td>
@@ -32,10 +36,6 @@
<th scope="row">Installation</th> <th scope="row">Installation</th>
<td>{{ object.installation|linkify }}</td> <td>{{ object.installation|linkify }}</td>
</tr> </tr>
<tr>
<th scope="row">Type</th>
<td>{{ object.type }}</td>
</tr>
<tr> <tr>
<th scope="row">Stored location</th> <th scope="row">Stored location</th>
{% if object.stored_location_url %} {% if object.stored_location_url %}
+11 -102
View File
@@ -1,106 +1,15 @@
from django.urls import path from django.urls import path, include
from netbox.views.generic import ObjectChangeLogView from netbox_slm import views # noqa F401
from netbox_slm import views from utilities.urls import get_model_urls
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
urlpatterns = [ urlpatterns = [
# SoftwareProduct path("software-products/", include(get_model_urls("netbox_slm", "softwareproduct", detail=False))),
path("software-products/", views.SoftwareProductListView.as_view(), name="softwareproduct_list"), path("software-products/<int:pk>/", include(get_model_urls("netbox_slm", "softwareproduct"))),
path("software-products/add/", views.SoftwareProductEditView.as_view(), name="softwareproduct_add"), path("versions/", include(get_model_urls("netbox_slm", "softwareproductversion", detail=False))),
path( path("versions/<int:pk>/", include(get_model_urls("netbox_slm", "softwareproductversion"))),
"software-products/delete/", views.SoftwareProductBulkDeleteView.as_view(), name="softwareproduct_bulk_delete" path("installations/", include(get_model_urls("netbox_slm", "softwareproductinstallation", detail=False))),
), path("installations/<int:pk>/", include(get_model_urls("netbox_slm", "softwareproductinstallation"))),
path("software-products/import/", views.SoftwareProductBulkImportView.as_view(), name="softwareproduct_import"), path("licenses/", include(get_model_urls("netbox_slm", "softwarelicense", detail=False))),
path("software-products/<int:pk>/", views.SoftwareProductView.as_view(), name="softwareproduct"), path("licenses/<int:pk>/", include(get_model_urls("netbox_slm", "softwarelicense"))),
path(
"software-products/<int:pk>/delete/", views.SoftwareProductDeleteView.as_view(), name="softwareproduct_delete"
),
path("software-products/<int:pk>/edit/", views.SoftwareProductEditView.as_view(), name="softwareproduct_edit"),
path(
"software-products/<int:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="softwareproduct_changelog",
kwargs={"model": SoftwareProduct},
),
# SoftwareProductVersion
path("versions/", views.SoftwareProductVersionListView.as_view(), name="softwareproductversion_list"),
path("versions/add/", views.SoftwareProductVersionEditView.as_view(), name="softwareproductversion_add"),
path(
"versions/delete/",
views.SoftwareProductVersionBulkDeleteView.as_view(),
name="softwareproductversion_bulk_delete",
),
path(
"versions/import/", views.SoftwareProductVersionBulkImportView.as_view(), name="softwareproductversion_import"
),
path("versions/<int:pk>/", views.SoftwareProductVersionView.as_view(), name="softwareproductversion"),
path(
"versions/<int:pk>/delete/",
views.SoftwareProductVersionDeleteView.as_view(),
name="softwareproductversion_delete",
),
path("versions/<int:pk>/edit/", views.SoftwareProductVersionEditView.as_view(), name="softwareproductversion_edit"),
path(
"versions/<int:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="softwareproductversion_changelog",
kwargs={"model": SoftwareProductVersion},
),
# SoftwareProductInstallation
path(
"installations/",
views.SoftwareProductInstallationListView.as_view(),
name="softwareproductinstallation_list",
),
path(
"installations/add/",
views.SoftwareProductInstallationEditView.as_view(),
name="softwareproductinstallation_add",
),
path(
"installations/delete/",
views.SoftwareProductInstallationBulkDeleteView.as_view(),
name="softwareproductinstallation_bulk_delete",
),
path(
"installations/import/",
views.SoftwareProductInstallationBulkImportView.as_view(),
name="softwareproductinstallation_import",
),
path(
"installations/<int:pk>/",
views.SoftwareProductInstallationView.as_view(),
name="softwareproductinstallation",
),
path(
"installations/<int:pk>/delete/",
views.SoftwareProductInstallationDeleteView.as_view(),
name="softwareproductinstallation_delete",
),
path(
"installations/<int:pk>/edit/",
views.SoftwareProductInstallationEditView.as_view(),
name="softwareproductinstallation_edit",
),
path(
"installations/<int:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="softwareproductinstallation_changelog",
kwargs={"model": SoftwareProductInstallation},
),
# SoftwareLicense
path("licenses/", views.SoftwareLicenseListView.as_view(), name="softwarelicense_list"),
path("licenses/add/", views.SoftwareLicenseEditView.as_view(), name="softwarelicense_add"),
path("licenses/delete/", views.SoftwareLicenseBulkDeleteView.as_view(), name="softwarelicense_bulk_delete"),
path("licenses/import/", views.SoftwareLicenseBulkImportView.as_view(), name="softwarelicense_import"),
path("licenses/<int:pk>/", views.SoftwareLicenseView.as_view(), name="softwarelicense"),
path("licenses/<int:pk>/delete/", views.SoftwareLicenseDeleteView.as_view(), name="softwarelicense_delete"),
path("licenses/<int:pk>/edit/", views.SoftwareLicenseEditView.as_view(), name="softwarelicense_edit"),
path(
"licenses/<int:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="softwarelicense_changelog",
kwargs={"model": SoftwareLicense},
),
] ]
+22 -14
View File
@@ -1,42 +1,50 @@
from netbox.views import generic from netbox.views import generic
from netbox_slm import filtersets, forms, tables from netbox_slm import filtersets, forms, tables
from netbox_slm.models import SoftwareLicense from netbox_slm.models import SoftwareLicense
from utilities.views import register_model_view
@register_model_view(SoftwareLicense, "list", path="", detail=False)
class SoftwareLicenseListView(generic.ObjectListView): class SoftwareLicenseListView(generic.ObjectListView):
"""View for listing all existing SoftwareLicenses."""
queryset = SoftwareLicense.objects.all() queryset = SoftwareLicense.objects.all()
filterset = filtersets.SoftwareLicenseFilterSet filterset = filtersets.SoftwareLicenseFilterSet
filterset_form = forms.SoftwareLicenseFilterForm filterset_form = forms.SoftwareLicenseFilterForm
table = tables.SoftwareLicenseTable table = tables.SoftwareLicenseTable
@register_model_view(SoftwareLicense)
class SoftwareLicenseView(generic.ObjectView): class SoftwareLicenseView(generic.ObjectView):
"""Display SoftwareLicense details"""
queryset = SoftwareLicense.objects.all() queryset = SoftwareLicense.objects.all()
@register_model_view(SoftwareLicense, "add", detail=False)
@register_model_view(SoftwareLicense, "edit")
class SoftwareLicenseEditView(generic.ObjectEditView): class SoftwareLicenseEditView(generic.ObjectEditView):
"""View for editing and creating a SoftwareLicense instance."""
queryset = SoftwareLicense.objects.all() queryset = SoftwareLicense.objects.all()
form = forms.SoftwareLicenseForm form = forms.SoftwareLicenseForm
@register_model_view(SoftwareLicense, "delete")
class SoftwareLicenseDeleteView(generic.ObjectDeleteView): class SoftwareLicenseDeleteView(generic.ObjectDeleteView):
"""View for deleting a SoftwareLicense instance"""
queryset = SoftwareLicense.objects.all() queryset = SoftwareLicense.objects.all()
class SoftwareLicenseBulkDeleteView(generic.BulkDeleteView): @register_model_view(SoftwareLicense, "bulk_import", detail=False)
queryset = SoftwareLicense.objects.all()
table = tables.SoftwareLicenseTable
class SoftwareLicenseBulkImportView(generic.BulkImportView): class SoftwareLicenseBulkImportView(generic.BulkImportView):
queryset = SoftwareLicense.objects.all() queryset = SoftwareLicense.objects.all()
table = tables.SoftwareLicenseTable
model_form = forms.SoftwareLicenseBulkImportForm model_form = forms.SoftwareLicenseBulkImportForm
@register_model_view(SoftwareLicense, "bulk_edit", path="edit", detail=False)
class SoftwareLicenseBulkEditView(generic.BulkEditView):
queryset = SoftwareLicense.objects.all()
filterset = filtersets.SoftwareLicenseFilterSet
table = tables.SoftwareLicenseTable
form = forms.SoftwareLicenseBulkEditForm
@register_model_view(SoftwareLicense, "bulk_delete", path="delete", detail=False)
class SoftwareLicenseBulkDeleteView(generic.BulkDeleteView):
queryset = SoftwareLicense.objects.all()
filterset = filtersets.SoftwareLicenseFilterSet
table = tables.SoftwareLicenseTable
+22 -14
View File
@@ -1,20 +1,19 @@
from netbox.views import generic from netbox.views import generic
from netbox_slm import filtersets, forms, tables from netbox_slm import filtersets, forms, tables
from netbox_slm.models import SoftwareProduct from netbox_slm.models import SoftwareProduct
from utilities.views import register_model_view
@register_model_view(SoftwareProduct, "list", path="", detail=False)
class SoftwareProductListView(generic.ObjectListView): class SoftwareProductListView(generic.ObjectListView):
"""View for listing all existing SoftwareProducts."""
queryset = SoftwareProduct.objects.all() queryset = SoftwareProduct.objects.all()
filterset = filtersets.SoftwareProductFilterSet filterset = filtersets.SoftwareProductFilterSet
filterset_form = forms.SoftwareProductFilterForm filterset_form = forms.SoftwareProductFilterForm
table = tables.SoftwareProductTable table = tables.SoftwareProductTable
@register_model_view(SoftwareProduct)
class SoftwareProductView(generic.ObjectView): class SoftwareProductView(generic.ObjectView):
"""Display SoftwareProduct details"""
queryset = SoftwareProduct.objects.all() queryset = SoftwareProduct.objects.all()
def get_extra_context(self, request, instance): def get_extra_context(self, request, instance):
@@ -22,25 +21,34 @@ class SoftwareProductView(generic.ObjectView):
return {"versions": versions} return {"versions": versions}
@register_model_view(SoftwareProduct, "add", detail=False)
@register_model_view(SoftwareProduct, "edit")
class SoftwareProductEditView(generic.ObjectEditView): class SoftwareProductEditView(generic.ObjectEditView):
"""View for editing and creating a SoftwareProduct instance."""
queryset = SoftwareProduct.objects.all() queryset = SoftwareProduct.objects.all()
form = forms.SoftwareProductForm form = forms.SoftwareProductForm
@register_model_view(SoftwareProduct, "delete")
class SoftwareProductDeleteView(generic.ObjectDeleteView): class SoftwareProductDeleteView(generic.ObjectDeleteView):
"""View for deleting a SoftwareProduct instance"""
queryset = SoftwareProduct.objects.all() queryset = SoftwareProduct.objects.all()
class SoftwareProductBulkDeleteView(generic.BulkDeleteView): @register_model_view(SoftwareProduct, "bulk_import", detail=False)
queryset = SoftwareProduct.objects.all()
table = tables.SoftwareProductTable
class SoftwareProductBulkImportView(generic.BulkImportView): class SoftwareProductBulkImportView(generic.BulkImportView):
queryset = SoftwareProduct.objects.all() queryset = SoftwareProduct.objects.all()
table = tables.SoftwareProductTable
model_form = forms.SoftwareProductBulkImportForm model_form = forms.SoftwareProductBulkImportForm
@register_model_view(SoftwareProduct, "bulk_edit", path="edit", detail=False)
class SoftwareProductBulkEditView(generic.BulkEditView):
queryset = SoftwareProduct.objects.all()
filterset = filtersets.SoftwareProductFilterSet
table = tables.SoftwareProductTable
form = forms.SoftwareProductBulkEditForm
@register_model_view(SoftwareProduct, "bulk_delete", path="delete", detail=False)
class SoftwareProductBulkDeleteView(generic.BulkDeleteView):
queryset = SoftwareProduct.objects.all()
filterset = filtersets.SoftwareProductFilterSet
table = tables.SoftwareProductTable
@@ -1,42 +1,50 @@
from netbox.views import generic from netbox.views import generic
from netbox_slm import filtersets, forms, tables from netbox_slm import filtersets, forms, tables
from netbox_slm.models import SoftwareProductInstallation from netbox_slm.models import SoftwareProductInstallation
from utilities.views import register_model_view
@register_model_view(SoftwareProductInstallation, "list", path="", detail=False)
class SoftwareProductInstallationListView(generic.ObjectListView): class SoftwareProductInstallationListView(generic.ObjectListView):
"""View for listing all existing SoftwareProductInstallations."""
queryset = SoftwareProductInstallation.objects.all() queryset = SoftwareProductInstallation.objects.all()
filterset = filtersets.SoftwareProductInstallationFilterSet filterset = filtersets.SoftwareProductInstallationFilterSet
filterset_form = forms.SoftwareProductInstallationFilterForm filterset_form = forms.SoftwareProductInstallationFilterForm
table = tables.SoftwareProductInstallationTable table = tables.SoftwareProductInstallationTable
@register_model_view(SoftwareProductInstallation)
class SoftwareProductInstallationView(generic.ObjectView): class SoftwareProductInstallationView(generic.ObjectView):
"""Display SoftwareProductInstallation details"""
queryset = SoftwareProductInstallation.objects.all() queryset = SoftwareProductInstallation.objects.all()
@register_model_view(SoftwareProductInstallation, "add", detail=False)
@register_model_view(SoftwareProductInstallation, "edit")
class SoftwareProductInstallationEditView(generic.ObjectEditView): class SoftwareProductInstallationEditView(generic.ObjectEditView):
"""View for editing and creating a SoftwareProductInstallation instance."""
queryset = SoftwareProductInstallation.objects.all() queryset = SoftwareProductInstallation.objects.all()
form = forms.SoftwareProductInstallationForm form = forms.SoftwareProductInstallationForm
@register_model_view(SoftwareProductInstallation, "delete")
class SoftwareProductInstallationDeleteView(generic.ObjectDeleteView): class SoftwareProductInstallationDeleteView(generic.ObjectDeleteView):
"""View for deleting a SoftwareProductInstallation instance"""
queryset = SoftwareProductInstallation.objects.all() queryset = SoftwareProductInstallation.objects.all()
class SoftwareProductInstallationBulkDeleteView(generic.BulkDeleteView): @register_model_view(SoftwareProductInstallation, "bulk_import", detail=False)
queryset = SoftwareProductInstallation.objects.all()
table = tables.SoftwareProductInstallationTable
class SoftwareProductInstallationBulkImportView(generic.BulkImportView): class SoftwareProductInstallationBulkImportView(generic.BulkImportView):
queryset = SoftwareProductInstallation.objects.all() queryset = SoftwareProductInstallation.objects.all()
table = tables.SoftwareProductInstallationTable
model_form = forms.SoftwareProductInstallationBulkImportForm model_form = forms.SoftwareProductInstallationBulkImportForm
@register_model_view(SoftwareProductInstallation, "bulk_edit", path="edit", detail=False)
class SoftwareProductInstallationBulkEditView(generic.BulkEditView):
queryset = SoftwareProductInstallation.objects.all()
filterset = filtersets.SoftwareProductInstallationFilterSet
table = tables.SoftwareProductInstallationTable
form = forms.SoftwareProductInstallationBulkEditForm
@register_model_view(SoftwareProductInstallation, "bulk_delete", path="delete", detail=False)
class SoftwareProductInstallationBulkDeleteView(generic.BulkDeleteView):
queryset = SoftwareProductInstallation.objects.all()
filterset = filtersets.SoftwareProductInstallationFilterSet
table = tables.SoftwareProductInstallationTable
+22 -14
View File
@@ -1,20 +1,19 @@
from netbox.views import generic from netbox.views import generic
from netbox_slm import filtersets, forms, tables from netbox_slm import filtersets, forms, tables
from netbox_slm.models import SoftwareProductVersion from netbox_slm.models import SoftwareProductVersion
from utilities.views import register_model_view
@register_model_view(SoftwareProductVersion, "list", path="", detail=False)
class SoftwareProductVersionListView(generic.ObjectListView): class SoftwareProductVersionListView(generic.ObjectListView):
"""View for listing all existing SoftwareProductVersions."""
queryset = SoftwareProductVersion.objects.all() queryset = SoftwareProductVersion.objects.all()
filterset = filtersets.SoftwareProductVersionFilterSet filterset = filtersets.SoftwareProductVersionFilterSet
filterset_form = forms.SoftwareProductVersionFilterForm filterset_form = forms.SoftwareProductVersionFilterForm
table = tables.SoftwareProductVersionTable table = tables.SoftwareProductVersionTable
@register_model_view(SoftwareProductVersion)
class SoftwareProductVersionView(generic.ObjectView): class SoftwareProductVersionView(generic.ObjectView):
"""Display SoftwareProductVersion details"""
queryset = SoftwareProductVersion.objects.all() queryset = SoftwareProductVersion.objects.all()
def get_extra_context(self, request, instance): def get_extra_context(self, request, instance):
@@ -22,25 +21,34 @@ class SoftwareProductVersionView(generic.ObjectView):
return {"installations": installation_count} return {"installations": installation_count}
@register_model_view(SoftwareProductVersion, "add", detail=False)
@register_model_view(SoftwareProductVersion, "edit")
class SoftwareProductVersionEditView(generic.ObjectEditView): class SoftwareProductVersionEditView(generic.ObjectEditView):
"""View for editing and creating a SoftwareProductVersion instance."""
queryset = SoftwareProductVersion.objects.all() queryset = SoftwareProductVersion.objects.all()
form = forms.SoftwareProductVersionForm form = forms.SoftwareProductVersionForm
@register_model_view(SoftwareProductVersion, "delete")
class SoftwareProductVersionDeleteView(generic.ObjectDeleteView): class SoftwareProductVersionDeleteView(generic.ObjectDeleteView):
"""View for deleting a SoftwareProductVersion instance"""
queryset = SoftwareProductVersion.objects.all() queryset = SoftwareProductVersion.objects.all()
class SoftwareProductVersionBulkDeleteView(generic.BulkDeleteView): @register_model_view(SoftwareProductVersion, "bulk_import", detail=False)
queryset = SoftwareProductVersion.objects.all()
table = tables.SoftwareProductVersionTable
class SoftwareProductVersionBulkImportView(generic.BulkImportView): class SoftwareProductVersionBulkImportView(generic.BulkImportView):
queryset = SoftwareProductVersion.objects.all() queryset = SoftwareProductVersion.objects.all()
table = tables.SoftwareProductVersionTable
model_form = forms.SoftwareProductVersionBulkImportForm model_form = forms.SoftwareProductVersionBulkImportForm
@register_model_view(SoftwareProductVersion, "bulk_edit", path="edit", detail=False)
class SoftwareProductVersionBulkEditView(generic.BulkEditView):
queryset = SoftwareProductVersion.objects.all()
filterset = filtersets.SoftwareProductVersionFilterSet
table = tables.SoftwareProductVersionTable
form = forms.SoftwareProductVersionBulkEditForm
@register_model_view(SoftwareProductVersion, "bulk_delete", path="delete", detail=False)
class SoftwareProductVersionBulkDeleteView(generic.BulkDeleteView):
queryset = SoftwareProductVersion.objects.all()
filterset = filtersets.SoftwareProductVersionFilterSet
table = tables.SoftwareProductVersionTable