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>
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
from django.forms import DateField
|
|
from django.urls import reverse_lazy
|
|
|
|
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
|
|
from utilities.forms.widgets import APISelect, DatePicker
|
|
|
|
|
|
class SoftwareProductVersionForm(NetBoxModelForm):
|
|
"""Form for creating a new SoftwareProductVersion object."""
|
|
|
|
comments = CommentField()
|
|
|
|
release_date = DateField(required=False, widget=DatePicker())
|
|
end_of_support = DateField(required=False, widget=DatePicker())
|
|
|
|
software_product = DynamicModelChoiceField(
|
|
queryset=SoftwareProduct.objects.all(),
|
|
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}),
|
|
)
|
|
|
|
class Meta:
|
|
model = SoftwareProductVersion
|
|
fields = (
|
|
"name",
|
|
"software_product",
|
|
"release_date",
|
|
"documentation_url",
|
|
"end_of_support",
|
|
"filename",
|
|
"file_checksum",
|
|
"file_link",
|
|
"release_type",
|
|
"tags",
|
|
"comments",
|
|
)
|
|
|
|
|
|
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",
|
|
)
|