Skip to content

Commit

Permalink
Fixes issue with fieldsets (#25)
Browse files Browse the repository at this point in the history
* Update readme

* Version bump

* Fix fieldsets
  • Loading branch information
DanSheps authored Sep 9, 2024
1 parent 0301326 commit 6d6b72b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion netbox_routing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NetboxRouting(PluginConfig):
author = plugin.get('Author')
author_email = plugin.get('Author-email')
base_url = 'routing'
min_version = '3.5.0'
min_version = '4.1.0'
required_settings = []
caching_config = {}
default_settings = {}
Expand Down
34 changes: 14 additions & 20 deletions netbox_routing/forms/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
'BGPSettingForm',
)

from utilities.forms.rendering import FieldSet


class BGPSettingMixin:
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -162,11 +164,9 @@ class BGPRouterForm(BGPSettingMixin, NetBoxModelForm):
)


fieldsets = [
(_('Router'), (
'device', 'asn',
)),
]
fieldsets = (
FieldSet('device', 'asn', name=_('Router')),
)

class Meta:
model = BGPRouter
Expand All @@ -191,11 +191,9 @@ class BGPScopeForm(BGPSettingMixin, NetBoxModelForm):
)


fieldsets = [
(_('Scope'), (
'router', 'vrf',
)),
]
fieldsets = (
FieldSet('router', 'vrf', name=_('Scope')),
)

class Meta:
model = BGPScope
Expand All @@ -219,11 +217,9 @@ class BGPAddressFamilyForm(BGPSettingMixin, NetBoxModelForm):
)


fieldsets = [
(_('Address Family'), (
'scope', 'address_family',
)),
]
fieldsets = (
FieldSet('scope', 'address_family', name=_('Address Family')),
)

class Meta:
model = BGPAddressFamily
Expand All @@ -245,11 +241,9 @@ class BGPSettingForm(NetBoxModelForm):
)


fieldsets = [
(_('Settings'), (
'key', 'value',
)),
]
fieldsets = (
FieldSet('key', 'value', name=_('Settings')),
)

class Meta:
model = BGPSetting
Expand Down
6 changes: 4 additions & 2 deletions netbox_routing/forms/bulk_edit/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
'RouteMapEntryBulkEditForm'
)

from utilities.forms.rendering import FieldSet


class PrefixListEntryBulkEditForm(NetBoxModelBulkEditForm):
prefix_list = DynamicModelChoiceField(
Expand All @@ -22,7 +24,7 @@ class PrefixListEntryBulkEditForm(NetBoxModelBulkEditForm):

model = PrefixListEntry
fieldsets = (
(None, ('prefix_list', )),
FieldSet('prefix_list'),
)
nullable_fields = ()

Expand All @@ -37,6 +39,6 @@ class RouteMapEntryBulkEditForm(NetBoxModelBulkEditForm):

model = RouteMapEntry
fieldsets = (
(None, ('route_map', )),
FieldSet('route_map'),
)
nullable_fields = ()
10 changes: 6 additions & 4 deletions netbox_routing/forms/filtersets/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
'BGPSettingFilterForm',
)

from utilities.forms.rendering import FieldSet


class BGPRouterFilterForm(NetBoxModelFilterSetForm):
device_id = DynamicModelMultipleChoiceField(
Expand All @@ -32,7 +34,7 @@ class BGPRouterFilterForm(NetBoxModelFilterSetForm):
)
model = BGPRouter
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'device_id', 'asn_id')),
FieldSet('q', 'filter_id', 'tag', 'device_id', 'asn_id'),
)
tag = TagFilterField(model)

Expand All @@ -52,7 +54,7 @@ class BGPScopeFilterForm(NetBoxModelFilterSetForm):
)
model = BGPScope
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'router_id', 'vrf_id')),
FieldSet('q', 'filter_id', 'tag', 'router_id', 'vrf_id'),
)
tag = TagFilterField(model)

Expand All @@ -71,14 +73,14 @@ class BGPAddressFamilyFilterForm(NetBoxModelFilterSetForm):
)
model = BGPAddressFamily
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'scope_id', 'address_family')),
FieldSet('q', 'filter_id', 'tag', 'scope_id', 'address_family'),
)
tag = TagFilterField(model)


class BGPSettingFilterForm(NetBoxModelFilterSetForm):
model = BGPSetting
fieldsets = (
(None, ('q', 'filter_id', 'tag', )),
FieldSet('q', 'filter_id', 'tag'),
)
tag = TagFilterField(model)
14 changes: 8 additions & 6 deletions netbox_routing/forms/filtersets/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
'OSPFInterfaceFilterForm',
)

from utilities.forms.rendering import FieldSet


class OSPFInstanceFilterForm(NetBoxModelFilterSetForm):
device = DynamicModelMultipleChoiceField(
Expand All @@ -26,26 +28,26 @@ class OSPFInstanceFilterForm(NetBoxModelFilterSetForm):
)
model = OSPFInstance
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'device')),
FieldSet('q', 'filter_id', 'tag', 'device'),
)
tag = TagFilterField(model)


class OSPFAreaFilterForm(NetBoxModelFilterSetForm):
model = OSPFArea
fieldsets = (
(None, ('q', 'filter_id', 'tag', )),
FieldSet('q', 'filter_id', 'tag'),
)
tag = TagFilterField(model)


class OSPFInterfaceFilterForm(NetBoxModelFilterSetForm):
model = OSPFInterface
fieldsets = (
(None, ('q', 'filter_id', 'tag', )),
('OSPF', ('instance', 'area')),
('Device', ('interface', )),
('Attributes', ('priority', 'bfd', 'authentication')),
FieldSet('q', 'filter_id', 'tag'),
FieldSet('instance', 'area', name=_('OSPF')),
FieldSet('interface', name=_('Device')),
FieldSet('priority', 'bfd', 'authentication', name=_('Attributes'))
)
instance = DynamicModelMultipleChoiceField(
queryset=OSPFInstance.objects.all(),
Expand Down
4 changes: 3 additions & 1 deletion netbox_routing/forms/filtersets/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
from utilities.forms.fields import DynamicModelMultipleChoiceField, TagFilterField
from django.utils.translation import gettext as _

from utilities.forms.rendering import FieldSet


class StaticRouteFilterForm(NetBoxModelFilterSetForm):
model = StaticRoute
fieldsets = (
(None, ('q', 'filter_id', 'tag', 'vrf')),
FieldSet('q', 'filter_id', 'tag', 'vrf'),
)
vrf = DynamicModelMultipleChoiceField(
queryset=VRF.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-routing',
version='0.2.0',
version='0.2.1',
description='NetBox Routing',
long_description='Plugin for documentation of routing configuration and objects',
url='https://github.com/dansheps/netbox-routing/',
Expand Down

0 comments on commit 6d6b72b

Please sign in to comment.