1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Move Filter and Form to new file, update all files

This commit is contained in:
dansheps
2019-04-10 08:37:12 -05:00
parent a91a79681f
commit 6e8e6809f3
14 changed files with 79 additions and 106 deletions

31
netbox/tenancy/formset.py Normal file
View File

@ -0,0 +1,31 @@
from django import forms
from utilities.forms import APISelectMultiple, FilterChoiceField
from .models import Tenant, TenantGroup
#
# Tenancy filtering form extension
#
class TenancyFilterForm(forms.Form):
tenant_group = FilterChoiceField(
queryset=TenantGroup.objects.all(),
to_field_name='slug',
null_label='-- None --',
widget=APISelectMultiple(
api_url="/api/tenancy/tenant-groups/",
value_field="slug",
null_option=True,
filter_for={
'tenant': 'group'
}
)
)
tenant = FilterChoiceField(
queryset=Tenant.objects.all(),
to_field_name='slug',
null_label='-- None --',
widget=APISelectMultiple(
api_url="/api/tenancy/tenants/",
value_field="slug",
null_option=True,
)
)