Implement list filtering forms (#57)
Closes #54 Signed-off-by: wkoot <3715211+wkoot@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from django.forms import CharField
|
||||
|
||||
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.fields import CommentField, DynamicModelChoiceField, TagFilterField, DynamicModelMultipleChoiceField
|
||||
from utilities.forms.rendering import FieldSet
|
||||
|
||||
|
||||
@@ -28,9 +30,21 @@ class SoftwareProductForm(NetBoxModelForm):
|
||||
|
||||
class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
|
||||
model = SoftwareProduct
|
||||
fieldsets = (FieldSet(None, ("q", "tag")),)
|
||||
fieldsets = (
|
||||
FieldSet("q", "filter_id", "tag"),
|
||||
FieldSet("name", "description", "manufacturer"),
|
||||
)
|
||||
selector_fields = ("q", "filter_id", "name")
|
||||
|
||||
tag = TagFilterField(model)
|
||||
|
||||
name = CharField(required=False)
|
||||
description = CharField(required=False)
|
||||
manufacturer = DynamicModelMultipleChoiceField(
|
||||
queryset=Manufacturer.objects.all(),
|
||||
required=False,
|
||||
)
|
||||
|
||||
|
||||
class SoftwareProductBulkImportForm(NetBoxModelImportForm):
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user