-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from DanSheps/develop
Update bulk_edit forms
- Loading branch information
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |