Skip to content

Commit

Permalink
Merge pull request #31 from DanSheps/develop
Browse files Browse the repository at this point in the history
Update bulk_edit forms
  • Loading branch information
DanSheps authored Sep 16, 2024
2 parents 0e64d60 + 939065b commit d804766
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
5 changes: 4 additions & 1 deletion netbox_routing/forms/bulk_edit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from .static import *
from .objects import *
from .ospf import OSPFInterfaceBulkEditForm


__all__ = (

# Staticroute
'StaticRouteBulkEditForm',

# OSPF
'OSPFInterfaceBulkEditForm',

Expand Down
23 changes: 18 additions & 5 deletions netbox_routing/forms/bulk_edit/ospf.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
from django import forms
from django.utils.translation import gettext as _

from netbox.forms import NetBoxModelBulkEditForm
from netbox_routing.models import OSPFArea, OSPFInstance, OSPFInterface
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES, add_blank_choice
from utilities.forms.fields import DynamicModelChoiceField

from netbox_routing import choices
from netbox_routing.models import OSPFArea, OSPFInstance, OSPFInterface

__all__ = (
'OSPFInterfaceBulkEditForm',
)

from utilities.forms.rendering import FieldSet


class OSPFInterfaceBulkEditForm(NetBoxModelBulkEditForm):
instance = DynamicModelChoiceField(
queryset=OSPFInstance.objects.all(),
label=_('Route Map'),
label=_('OSPF Instance'),
required=False,
selector=True
)
area = DynamicModelChoiceField(
queryset=OSPFArea.objects.all(),
label=_('Route Map'),
label=_('OSPF Area'),
required=False,
selector=True
)
priority = forms.IntegerField(label=_('Priority'), required=False)
bfd = forms.ChoiceField(label=_('BFD'), choices=BOOLEAN_WITH_BLANK_CHOICES, required=False)
authentication = forms.ChoiceField(
label=_('Authentication'),
choices=add_blank_choice(choices.AuthenticationChoices),
required=False
)
passphrase = forms.CharField(label=_('Passphrase'), required=False)

model = OSPFInterface
fieldsets = (
('OSPF', ('instance', 'area')),
('Attributes', ('priority', 'bfd', 'authentication', 'passphrase')),
FieldSet('instance', 'area', name='OSPF'),
FieldSet('priority', 'bfd', 'authentication', 'passphrase', name='Attributes'),
)
nullable_fields = ()
41 changes: 41 additions & 0 deletions netbox_routing/forms/bulk_edit/static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django import forms
from django.utils.translation import gettext as _

from dcim.models import Device
from ipam.models import VRF
from netbox.forms import NetBoxModelBulkEditForm
from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES
from utilities.forms.fields import DynamicModelChoiceField, DynamicModelMultipleChoiceField
from utilities.forms.rendering import FieldSet

from netbox_routing.models import StaticRoute


__all__ = (
'StaticRouteBulkEditForm',
)


class StaticRouteBulkEditForm(NetBoxModelBulkEditForm):
devices = DynamicModelMultipleChoiceField(
label='Device',
queryset=Device.objects.all(),
required=False,
selector=True,
)
vrf = DynamicModelChoiceField(
label='VRF',
queryset=VRF.objects.all(),
required=False,
selector=True,
)
metric = forms.IntegerField(label=_('Metric'), required=False)
permanent = forms.ChoiceField(label=_('Permanent'), choices=BOOLEAN_WITH_BLANK_CHOICES, required=False)

model = StaticRoute
fieldsets = (
FieldSet('devices', 'vrf', 'prefix', 'next_hop', name='Route'),
FieldSet('metric', 'permanent', name='Attributes'),
FieldSet('description', 'comments')
)
nullable_fields = ('devices', 'vrf', 'metric', 'permanent', 'description', 'comments')

0 comments on commit d804766

Please sign in to comment.