Initial work on NetBox v3.2 support (#88)
Co-authored-by: mattieserver <3049868+mattieserver@users.noreply.github.com>
This commit is contained in:
co-authored by
mattieserver
parent
e68a8a1af0
commit
62c0dbddb2
@@ -1,26 +1,30 @@
|
||||
import imp
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from extras.models import Tag
|
||||
from dcim.models import Device, Site, Region, DeviceRole, Location
|
||||
|
||||
from django import forms
|
||||
from tenancy.models import TenantGroup, Tenant
|
||||
from tenancy.forms import TenancyFilterForm
|
||||
from django.conf import settings
|
||||
from netbox.forms import NetBoxModelFilterSetForm
|
||||
from utilities.forms import (TagFilterField, DynamicModelMultipleChoiceField)
|
||||
|
||||
from utilities.forms import (TagFilterField, DynamicModelMultipleChoiceField, FilterForm)
|
||||
allow_coordinates_saving = settings.PLUGINS_CONFIG["netbox_topology_views"]["allow_coordinates_saving"]
|
||||
|
||||
class DeviceFilterForm(TenancyFilterForm, FilterForm):
|
||||
|
||||
class DeviceFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
model = Device
|
||||
field_groups = [
|
||||
['q', 'hide_unconnected', 'save_coords'],
|
||||
['tenant_group_id', 'tenant_id'],
|
||||
['region_id', 'site_id', 'location_id'],
|
||||
['device_role_id'],
|
||||
['tag'],
|
||||
]
|
||||
fieldsets = (
|
||||
(None, ('q', 'hide_unconnected', 'save_coords')),
|
||||
(None, ('tenant_group_id', 'tenant_id')),
|
||||
(None, ('region_id', 'site_id', 'location_id')),
|
||||
(None, ('device_role_id',)),
|
||||
(None, ('tag',)),
|
||||
)
|
||||
|
||||
region_id = DynamicModelMultipleChoiceField(
|
||||
queryset=Region.objects.all(),
|
||||
@@ -49,7 +53,6 @@ class DeviceFilterForm(TenancyFilterForm, FilterForm):
|
||||
},
|
||||
label=_('Location')
|
||||
)
|
||||
|
||||
hide_unconnected = forms.BooleanField(
|
||||
label=_("Hide Unconnected"),
|
||||
required=False,
|
||||
@@ -60,5 +63,4 @@ class DeviceFilterForm(TenancyFilterForm, FilterForm):
|
||||
required=False,
|
||||
disabled=(not allow_coordinates_saving),
|
||||
initial=False)
|
||||
|
||||
tag = TagFilterField(model)
|
||||
|
||||
Reference in New Issue
Block a user