mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
add dns_name field in the filterset field and remove extra method
This commit is contained in:
parent
6a06b54348
commit
384d978437
@ -618,14 +618,10 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
role = django_filters.MultipleChoiceFilter(
|
||||
choices=IPAddressRoleChoices
|
||||
)
|
||||
dns_name = MultiValueCharFilter(
|
||||
method='search_by_dns',
|
||||
label=_('DNS Name'),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = IPAddress
|
||||
fields = ['id', 'description']
|
||||
fields = ['id', 'dns_name', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -742,17 +738,6 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
assigned_object_id__isnull=True
|
||||
)
|
||||
|
||||
def search_by_dns(self, queryset, name, value):
|
||||
if not value:
|
||||
return queryset
|
||||
|
||||
normalized_value = str(value[0]).lower()
|
||||
|
||||
if normalized_value in ('none', 'null'):
|
||||
return queryset.filter(dns_name='')
|
||||
|
||||
return queryset.filter(dns_name__in=value)
|
||||
|
||||
|
||||
class FHRPGroupFilterSet(NetBoxModelFilterSet):
|
||||
protocol = django_filters.MultipleChoiceFilter(
|
||||
|
@ -359,12 +359,7 @@ class IPAddressFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
)
|
||||
dns_name = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'DNS Name',
|
||||
}
|
||||
),
|
||||
label='DNS Name'
|
||||
label=_('DNS Name')
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user