Assorted fixes (#25)
* Updated imports for Netbox 3.6.1 Closes #21 and #23 * Changed Fieldtypes of Start and Expiration Date Closes #22 * Bump to NetBox v3.6.1 * Add pyproject.toml and python workflow --------- Co-authored-by: Manuel Hartung <manuel.hartung@atos.net>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from django.forms import DateField
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
|
||||
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
|
||||
from utilities.forms import DynamicModelChoiceField, APISelect, TagFilterField
|
||||
from utilities.forms.fields import DynamicModelChoiceField, TagFilterField
|
||||
from utilities.forms.widgets import APISelect, DatePicker
|
||||
|
||||
|
||||
class SoftwareLicenseForm(NetBoxModelForm):
|
||||
@@ -11,19 +14,15 @@ class SoftwareLicenseForm(NetBoxModelForm):
|
||||
software_product = DynamicModelChoiceField(
|
||||
queryset=SoftwareProduct.objects.all(),
|
||||
required=True,
|
||||
widget=APISelect(
|
||||
attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}
|
||||
),
|
||||
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}),
|
||||
)
|
||||
version = DynamicModelChoiceField(
|
||||
queryset=SoftwareProductVersion.objects.all(),
|
||||
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={
|
||||
'software_product': '$software_product',
|
||||
}
|
||||
"software_product": "$software_product",
|
||||
},
|
||||
)
|
||||
installation = DynamicModelChoiceField(
|
||||
queryset=SoftwareProductInstallation.objects.all(),
|
||||
@@ -32,20 +31,38 @@ class SoftwareLicenseForm(NetBoxModelForm):
|
||||
attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproductinstallation-list")}
|
||||
),
|
||||
query_params={
|
||||
'software_product': '$software_product',
|
||||
}
|
||||
"software_product": "$software_product",
|
||||
},
|
||||
)
|
||||
start_date = DateField(label=_("Start date"), required=False, widget=DatePicker())
|
||||
expiration_date = DateField(label=_("Expiration date"), required=False, widget=DatePicker())
|
||||
|
||||
class Meta:
|
||||
model = SoftwareLicense
|
||||
fields = ("name", "description", "type", "stored_location", "start_date", "expiration_date",
|
||||
"software_product", "version", "installation", "tags")
|
||||
fields = (
|
||||
"name",
|
||||
"description",
|
||||
"type",
|
||||
"stored_location",
|
||||
"start_date",
|
||||
"expiration_date",
|
||||
"software_product",
|
||||
"version",
|
||||
"installation",
|
||||
"tags",
|
||||
)
|
||||
|
||||
|
||||
class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
|
||||
model = SoftwareLicense
|
||||
fieldsets = (
|
||||
(None, ('q', 'tag',)),
|
||||
(
|
||||
None,
|
||||
(
|
||||
"q",
|
||||
"tag",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
tag = TagFilterField(model)
|
||||
@@ -54,23 +71,28 @@ class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
|
||||
class SoftwareLicenseImportForm(NetBoxModelImportForm):
|
||||
class Meta:
|
||||
model = SoftwareLicense
|
||||
fields = ("name", "description", "type", "stored_location", "start_date", "expiration_date",)
|
||||
fields = (
|
||||
"name",
|
||||
"description",
|
||||
"type",
|
||||
"stored_location",
|
||||
"start_date",
|
||||
"expiration_date",
|
||||
)
|
||||
|
||||
|
||||
class SoftwareLicenseBulkEditForm(NetBoxModelBulkEditForm):
|
||||
software_product = DynamicModelChoiceField(
|
||||
queryset=SoftwareProduct.objects.all(),
|
||||
required=False
|
||||
)
|
||||
version = DynamicModelChoiceField(
|
||||
queryset=SoftwareProductVersion.objects.all(),
|
||||
required=False
|
||||
)
|
||||
installation = DynamicModelChoiceField(
|
||||
queryset=SoftwareProductInstallation.objects.all(),
|
||||
required=False
|
||||
)
|
||||
software_product = DynamicModelChoiceField(queryset=SoftwareProduct.objects.all(), required=False)
|
||||
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
|
||||
installation = DynamicModelChoiceField(queryset=SoftwareProductInstallation.objects.all(), required=False)
|
||||
model = SoftwareLicense
|
||||
fieldsets = (
|
||||
(None, ('software_product', 'version', 'installation',)),
|
||||
(
|
||||
None,
|
||||
(
|
||||
"software_product",
|
||||
"version",
|
||||
"installation",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user