Skip to content

Commit

Permalink
Fixes: #21 - Fix issue with fieldsets (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps authored Sep 9, 2024
2 parents 7e89642 + 8d14fec commit 65a06a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions netbox_lifecycle/forms/bulk_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from utilities.forms.fields import DynamicModelChoiceField

from netbox_lifecycle.models import SupportContract, SupportSKU, SupportContractAssignment, LicenseAssignment
from utilities.forms.rendering import FieldSet


class SupportContractAssignmentBulkEditForm(NetBoxModelBulkEditForm):
Expand All @@ -22,7 +23,7 @@ class SupportContractAssignmentBulkEditForm(NetBoxModelBulkEditForm):

model = SupportContractAssignment
fieldsets = (
(None, ('contract', 'sku')),
FieldSet('contract', 'sku'),
)
nullable_fields = ()

Expand All @@ -43,6 +44,6 @@ class LicenseAssignmentBulkEditForm(NetBoxModelBulkEditForm):

model = LicenseAssignment
fieldsets = (
(None, ('vendor', 'license', 'quantity')),
FieldSet('vendor', 'license', 'quantity'),
)
nullable_fields = ('quantity', )
25 changes: 13 additions & 12 deletions netbox_lifecycle/forms/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SupportContractAssignment, SupportSKU
from utilities.filters import MultiValueCharFilter, MultiValueNumberFilter
from utilities.forms.fields import DynamicModelMultipleChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelectMultiple


Expand All @@ -25,8 +26,8 @@
class HardwareLifecycleFilterForm(NetBoxModelFilterSetForm):
model = HardwareLifecycle
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('Hardware', ('assigned_object_type_id', ))
FieldSet('q', 'filter_id', 'tag'),
FieldSet('assigned_object_type_id', name=_('Hardware'))
)

assigned_object_type_id = DynamicModelMultipleChoiceField(
Expand All @@ -43,7 +44,7 @@ class HardwareLifecycleFilterForm(NetBoxModelFilterSetForm):
class SupportSKUFilterForm(NetBoxModelFilterSetForm):
model = SupportSKU
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'manufacturer_id')),
FieldSet('q', 'filter_id', 'tag', 'manufacturer_id'),
)
manufacturer_id = DynamicModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
Expand All @@ -57,8 +58,8 @@ class SupportSKUFilterForm(NetBoxModelFilterSetForm):
class SupportContractFilterForm(NetBoxModelFilterSetForm):
model = SupportContract
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('Purchase Information', ('vendor_id', )),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('vendor_id', name='Purchase Information'),
)
vendor_id = DynamicModelMultipleChoiceField(
queryset=Vendor.objects.all(),
Expand All @@ -72,16 +73,16 @@ class SupportContractFilterForm(NetBoxModelFilterSetForm):
class VendorFilterForm(NetBoxModelFilterSetForm):
model = Vendor
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
FieldSet('q', 'filter_id', 'tag'),
)
tag = TagFilterField(model)


class LicenseFilterForm(NetBoxModelFilterSetForm):
model = License
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('License Information', ('manufacturer_id', )),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('manufacturer_id', name='License Information'),
)
manufacturer_id = DynamicModelMultipleChoiceField(
queryset=Manufacturer.objects.all(),
Expand All @@ -95,8 +96,8 @@ class LicenseFilterForm(NetBoxModelFilterSetForm):
class SupportContractAssignmentFilterForm(NetBoxModelFilterSetForm):
model = SupportContractAssignment
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('Assignment', ('contract_id', 'device_id', 'license_id', )),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('contract_id', 'device_id', 'license_id', name='Assignment'),
)
contract_id = DynamicModelMultipleChoiceField(
queryset=SupportContract.objects.all(),
Expand All @@ -122,8 +123,8 @@ class SupportContractAssignmentFilterForm(NetBoxModelFilterSetForm):
class LicenseAssignmentFilterForm(NetBoxModelFilterSetForm):
model = LicenseAssignment
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('Assignment', ('license_id', 'vendor_id', 'device_id', )),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('license_id', 'vendor_id', 'device_id', name='Assignment'),
)
license_id = DynamicModelMultipleChoiceField(
queryset=License.objects.all(),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='netbox-lifecycle',
version='1.1.1',
version='1.1.2',
description='NetBox Lifecycle',
long_description='NetBox Support Contract and EOL/EOS management',
url='https://github.com/dansheps/netbox-lifecycle/',
Expand Down

0 comments on commit 65a06a1

Please sign in to comment.