mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-12 19:39:35 -06:00
Enable filter form modifiers on Tenancy models
This commit is contained in:
parent
8d191b5d5b
commit
9cb7f4b9ad
@ -7,11 +7,14 @@ from netbox.forms import (
|
|||||||
PrimaryModelFilterSetForm,
|
PrimaryModelFilterSetForm,
|
||||||
)
|
)
|
||||||
from tenancy.choices import *
|
from tenancy.choices import *
|
||||||
|
from tenancy.filtersets import *
|
||||||
from tenancy.models import *
|
from tenancy.models import *
|
||||||
from tenancy.forms import ContactModelFilterForm
|
from tenancy.forms import ContactModelFilterForm
|
||||||
from utilities.forms.fields import (
|
from utilities.forms.fields import (
|
||||||
ContentTypeMultipleChoiceField, DynamicModelMultipleChoiceField, TagFilterField,
|
ContentTypeMultipleChoiceField, DynamicModelMultipleChoiceField, TagFilterField,
|
||||||
)
|
)
|
||||||
|
from utilities.forms.filterset_mappings import FILTERSET_MAPPINGS
|
||||||
|
from utilities.forms.mixins import FilterModifierMixin
|
||||||
from utilities.forms.rendering import FieldSet
|
from utilities.forms.rendering import FieldSet
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -28,7 +31,7 @@ __all__ = (
|
|||||||
# Tenants
|
# Tenants
|
||||||
#
|
#
|
||||||
|
|
||||||
class TenantGroupFilterForm(NestedGroupModelFilterSetForm):
|
class TenantGroupFilterForm(FilterModifierMixin, NestedGroupModelFilterSetForm):
|
||||||
model = TenantGroup
|
model = TenantGroup
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
||||||
@ -42,7 +45,7 @@ class TenantGroupFilterForm(NestedGroupModelFilterSetForm):
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
class TenantFilterForm(ContactModelFilterForm, PrimaryModelFilterSetForm):
|
class TenantFilterForm(FilterModifierMixin, ContactModelFilterForm, PrimaryModelFilterSetForm):
|
||||||
model = Tenant
|
model = Tenant
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
||||||
@ -62,7 +65,7 @@ class TenantFilterForm(ContactModelFilterForm, PrimaryModelFilterSetForm):
|
|||||||
# Contacts
|
# Contacts
|
||||||
#
|
#
|
||||||
|
|
||||||
class ContactGroupFilterForm(NestedGroupModelFilterSetForm):
|
class ContactGroupFilterForm(FilterModifierMixin, NestedGroupModelFilterSetForm):
|
||||||
model = ContactGroup
|
model = ContactGroup
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
||||||
@ -76,7 +79,7 @@ class ContactGroupFilterForm(NestedGroupModelFilterSetForm):
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
class ContactRoleFilterForm(OrganizationalModelFilterSetForm):
|
class ContactRoleFilterForm(FilterModifierMixin, OrganizationalModelFilterSetForm):
|
||||||
model = ContactRole
|
model = ContactRole
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
||||||
@ -84,7 +87,7 @@ class ContactRoleFilterForm(OrganizationalModelFilterSetForm):
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
class ContactFilterForm(PrimaryModelFilterSetForm):
|
class ContactFilterForm(FilterModifierMixin, PrimaryModelFilterSetForm):
|
||||||
model = Contact
|
model = Contact
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
FieldSet('q', 'filter_id', 'tag', 'owner_id'),
|
||||||
@ -99,7 +102,7 @@ class ContactFilterForm(PrimaryModelFilterSetForm):
|
|||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
class ContactAssignmentFilterForm(FilterModifierMixin, NetBoxModelFilterSetForm):
|
||||||
model = ContactAssignment
|
model = ContactAssignment
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id', 'tag'),
|
FieldSet('q', 'filter_id', 'tag'),
|
||||||
@ -131,3 +134,12 @@ class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
|||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
|
# Register FilterSet mappings for FilterModifierMixin lookup verification
|
||||||
|
FILTERSET_MAPPINGS[ContactAssignmentFilterForm] = ContactAssignmentFilterSet
|
||||||
|
FILTERSET_MAPPINGS[ContactFilterForm] = ContactFilterSet
|
||||||
|
FILTERSET_MAPPINGS[ContactGroupFilterForm] = ContactGroupFilterSet
|
||||||
|
FILTERSET_MAPPINGS[ContactRoleFilterForm] = ContactRoleFilterSet
|
||||||
|
FILTERSET_MAPPINGS[TenantFilterForm] = TenantFilterSet
|
||||||
|
FILTERSET_MAPPINGS[TenantGroupFilterForm] = TenantGroupFilterSet
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user