Implement bulk imports and edits for SLM models (#46)

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>
This commit is contained in:
wkoot
2024-10-14 13:41:22 +02:00
committed by GitHub
co-authored by Eric Hester
parent 3539539c4e
commit a0a98bb407
12 changed files with 141 additions and 10 deletions
+12 -4
View File
@@ -1,4 +1,12 @@
from .software_license import SoftwareLicenseForm, SoftwareLicenseFilterForm
from .software_product import SoftwareProductForm, SoftwareProductFilterForm
from .software_product_installation import SoftwareProductInstallationForm, SoftwareProductInstallationFilterForm
from .software_product_version import SoftwareProductVersionForm, SoftwareProductVersionFilterForm
from .software_license import SoftwareLicenseForm, SoftwareLicenseFilterForm, SoftwareLicenseBulkImportForm
from .software_product import SoftwareProductForm, SoftwareProductFilterForm, SoftwareProductBulkImportForm
from .software_product_installation import (
SoftwareProductInstallationForm,
SoftwareProductInstallationFilterForm,
SoftwareProductInstallationBulkImportForm,
)
from .software_product_version import (
SoftwareProductVersionForm,
SoftwareProductVersionFilterForm,
SoftwareProductVersionBulkImportForm,
)
+21 -2
View File
@@ -1,7 +1,7 @@
from django.forms import DateField
from django.urls import reverse_lazy
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField, LaxURLField
from utilities.forms.rendering import FieldSet
@@ -46,6 +46,7 @@ class SoftwareLicenseForm(NetBoxModelForm):
fields = (
"name",
"description",
"software_product",
"type",
"stored_location",
"stored_location_url",
@@ -53,7 +54,6 @@ class SoftwareLicenseForm(NetBoxModelForm):
"expiration_date",
"support",
"license_amount",
"software_product",
"version",
"installation",
"tags",
@@ -65,3 +65,22 @@ class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
model = SoftwareLicense
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
class SoftwareLicenseBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareLicense
fields = (
"name",
"description",
"software_product",
"type",
"start_date",
"expiration_date",
"support",
"license_amount",
"version",
"installation",
"tags",
"comments",
)
+13 -1
View File
@@ -1,5 +1,5 @@
from dcim.models import Manufacturer
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
@@ -30,3 +30,15 @@ class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProduct
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
class SoftwareProductBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProduct
fields = (
"name",
"description",
"manufacturer",
"tags",
"comments",
)
@@ -2,7 +2,7 @@ from django.forms import ValidationError
from django.urls import reverse_lazy
from dcim.models import Device
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
@@ -59,3 +59,17 @@ class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductInstallation
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
class SoftwareProductInstallationBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProductInstallation
fields = (
"device",
"virtualmachine",
"cluster",
"software_product",
"version",
"tags",
"comments",
)
+18 -2
View File
@@ -1,7 +1,7 @@
from django.forms import DateField
from django.urls import reverse_lazy
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
@@ -25,6 +25,7 @@ class SoftwareProductVersionForm(NetBoxModelForm):
model = SoftwareProductVersion
fields = (
"name",
"software_product",
"release_date",
"documentation_url",
"end_of_support",
@@ -32,7 +33,6 @@ class SoftwareProductVersionForm(NetBoxModelForm):
"file_checksum",
"file_link",
"release_type",
"software_product",
"tags",
"comments",
)
@@ -42,3 +42,19 @@ class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductVersion
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm):
class Meta:
model = SoftwareProductVersion
fields = (
"name",
"software_product",
"release_date",
"end_of_support",
"filename",
"file_checksum",
"release_type",
"tags",
"comments",
)