Skip to content

Commit

Permalink
Add filtering Numbers by Provider support
Browse files Browse the repository at this point in the history
  • Loading branch information
iDebugAll committed Jul 8, 2021
1 parent d6a8402 commit 95074ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion phonebox_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PhoneBoxConfig(PluginConfig):
name = 'phonebox_plugin'
verbose_name = 'PhoneBox Plugin'
description = 'Telephone Number Management Plugin for NetBox.'
version = '0.0.1-beta.6'
version = '0.0.1-beta.7'
author = 'Igor Korotchenkov'
author_email = 'iDebugAll@gmail.com'
base_url = 'phonebox'
Expand Down
7 changes: 7 additions & 0 deletions phonebox_plugin/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import django_filters
from django.db.models import Q
from circuits.models import Provider
from dcim.models import Region
from tenancy.models import Tenant
from .models import Number
Expand Down Expand Up @@ -44,6 +45,12 @@ class NumberFilterSet(BaseFilterSet):
to_field_name='slug',
label='Region (slug)',
)
provider = django_filters.ModelMultipleChoiceFilter(
queryset=Provider.objects.all(),
field_name='provider__slug',
to_field_name='slug',
label='Region (slug)',
)
forward_to = django_filters.ModelMultipleChoiceFilter(
field_name='forward_to',
queryset=Number.objects.all(),
Expand Down
6 changes: 6 additions & 0 deletions phonebox_plugin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class NumberFilterForm(BootstrapMixin, forms.Form):
required=False,
null_option='None',
)
provider = DynamicModelMultipleChoiceField(
queryset=Provider.objects.all(),
to_field_name='slug',
required=False,
null_option='None',
)
tag = TagFilterField(model)


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

setup(
name='phonebox_plugin',
version='0.0.1-beta.6',
version='0.0.1-beta.7',
url='https://github.com/iDebugAll/phonebox-plugin.git',
download_url='https://github.com/iDebugAll/phonebox-plugin/archive/v0.0.1-beta.6.tar.gz',
download_url='https://github.com/iDebugAll/phonebox-plugin/archive/v0.0.1-beta.7.tar.gz',
description='A phone numbers management plugin for NetBox.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 95074ef

Please sign in to comment.