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>
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from dcim.models import Manufacturer
|
|
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
|
|
|
|
|
|
class SoftwareProductForm(NetBoxModelForm):
|
|
"""Form for creating a new SoftwareProduct object."""
|
|
|
|
comments = CommentField()
|
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
queryset=Manufacturer.objects.all(),
|
|
required=True,
|
|
)
|
|
|
|
class Meta:
|
|
model = SoftwareProduct
|
|
fields = (
|
|
"name",
|
|
"description",
|
|
"manufacturer",
|
|
"tags",
|
|
"comments",
|
|
)
|
|
|
|
|
|
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",
|
|
)
|