mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#12257 schema mappings for modelchoicefilter
This commit is contained in:
@ -7,6 +7,8 @@ from django.utils.translation import gettext as _
|
||||
from netaddr.core import AddrFormatError
|
||||
|
||||
from dcim.models import Device, Interface, Region, Site, SiteGroup
|
||||
from drf_spectacular.utils import extend_schema_field
|
||||
from drf_spectacular.types import OpenApiTypes
|
||||
from netbox.filtersets import ChangeLoggedModelFilterSet, OrganizationalModelFilterSet, NetBoxModelFilterSet
|
||||
from tenancy.filtersets import TenancyFilterSet
|
||||
from utilities.filters import (
|
||||
@ -284,17 +286,17 @@ class PrefixFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
to_field_name='rd',
|
||||
label=_('VRF (RD)'),
|
||||
)
|
||||
present_in_vrf_id = django_filters.ModelChoiceFilter(
|
||||
present_in_vrf_id = extend_schema_field({'type': 'string', 'description': 'VRF'})(django_filters.ModelChoiceFilter(
|
||||
queryset=VRF.objects.all(),
|
||||
method='filter_present_in_vrf',
|
||||
label=_('VRF')
|
||||
)
|
||||
present_in_vrf = django_filters.ModelChoiceFilter(
|
||||
))
|
||||
present_in_vrf = extend_schema_field({'type': 'string', 'description': 'VRF (RD)'})(django_filters.ModelChoiceFilter(
|
||||
queryset=VRF.objects.all(),
|
||||
method='filter_present_in_vrf',
|
||||
to_field_name='rd',
|
||||
label=_('VRF (RD)'),
|
||||
)
|
||||
))
|
||||
region_id = TreeNodeMultipleChoiceFilter(
|
||||
queryset=Region.objects.all(),
|
||||
field_name='site__region',
|
||||
@ -526,17 +528,17 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
to_field_name='rd',
|
||||
label=_('VRF (RD)'),
|
||||
)
|
||||
present_in_vrf_id = django_filters.ModelChoiceFilter(
|
||||
present_in_vrf_id = extend_schema_field({'type': 'string', 'description': 'VRF'})(django_filters.ModelChoiceFilter(
|
||||
queryset=VRF.objects.all(),
|
||||
method='filter_present_in_vrf',
|
||||
label=_('VRF')
|
||||
)
|
||||
present_in_vrf = django_filters.ModelChoiceFilter(
|
||||
))
|
||||
present_in_vrf = extend_schema_field({'type': 'string', 'description': 'VRF (RD)'})(django_filters.ModelChoiceFilter(
|
||||
queryset=VRF.objects.all(),
|
||||
method='filter_present_in_vrf',
|
||||
to_field_name='rd',
|
||||
label=_('VRF (RD)'),
|
||||
)
|
||||
))
|
||||
device = MultiValueCharFilter(
|
||||
method='filter_device',
|
||||
field_name='name',
|
||||
@ -907,14 +909,14 @@ class VLANFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
choices=VLANStatusChoices,
|
||||
null_value=None
|
||||
)
|
||||
available_on_device = django_filters.ModelChoiceFilter(
|
||||
available_on_device = extend_schema_field(OpenApiTypes.STR)(django_filters.ModelChoiceFilter(
|
||||
queryset=Device.objects.all(),
|
||||
method='get_for_device'
|
||||
)
|
||||
available_on_virtualmachine = django_filters.ModelChoiceFilter(
|
||||
))
|
||||
available_on_virtualmachine = extend_schema_field(OpenApiTypes.STR)(django_filters.ModelChoiceFilter(
|
||||
queryset=VirtualMachine.objects.all(),
|
||||
method='get_for_virtualmachine'
|
||||
)
|
||||
))
|
||||
l2vpn_id = django_filters.ModelMultipleChoiceFilter(
|
||||
field_name='l2vpn_terminations__l2vpn',
|
||||
queryset=L2VPN.objects.all(),
|
||||
|
Reference in New Issue
Block a user