netbox-plugin-device-map/netbox_device_map/forms.py

38 lines
1.2 KiB
Python
Raw Normal View History

2022-05-26 09:53:13 +03:00
from django import forms
from dcim.models import DeviceRole, Device
from ipam.models import VLANGroup, VLAN
from utilities.forms import BootstrapMixin
2023-05-03 01:00:20 +03:00
from utilities.forms.fields import DynamicModelChoiceField, DynamicModelMultipleChoiceField
2022-05-26 09:53:13 +03:00
class DeviceMapFilterForm(BootstrapMixin, forms.Form):
vlan_group = DynamicModelChoiceField(
queryset=VLANGroup.objects.all(),
required=False,
label="VLAN group",
help_text="VLAN group for VLAN selection"
)
vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(),
2024-05-03 12:20:11 +03:00
required=False,
2022-05-26 09:53:13 +03:00
label="VLAN",
help_text="Filter devices by VLAN attached to any device interface",
query_params={"group_id": "$vlan_group"}
)
device_roles = DynamicModelMultipleChoiceField(
queryset=DeviceRole.objects.all(),
required=False,
label="Device roles",
help_text="Display devices of only the specified device roles"
)
calculate_connections = forms.BooleanField(
required=False,
label="Calculate connections between devices",
initial=True
)
class ConnectedCpeForm(forms.Form):
vlan = forms.ModelChoiceField(queryset=VLAN.objects.all(), required=False)