mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
34 lines
754 B
Python
34 lines
754 B
Python
from extras.api.views import CustomFieldModelViewSet
|
|
from tenancy import filters
|
|
from tenancy.models import Tenant, TenantGroup
|
|
from utilities.api import FieldChoicesViewSet, ModelViewSet
|
|
from . import serializers
|
|
|
|
|
|
#
|
|
# Field choices
|
|
#
|
|
|
|
class TenancyFieldChoicesViewSet(FieldChoicesViewSet):
|
|
fields = ()
|
|
|
|
|
|
#
|
|
# Tenant Groups
|
|
#
|
|
|
|
class TenantGroupViewSet(ModelViewSet):
|
|
queryset = TenantGroup.objects.all()
|
|
serializer_class = serializers.TenantGroupSerializer
|
|
filterset_class = filters.TenantGroupFilter
|
|
|
|
|
|
#
|
|
# Tenants
|
|
#
|
|
|
|
class TenantViewSet(CustomFieldModelViewSet):
|
|
queryset = Tenant.objects.select_related('group').prefetch_related('tags')
|
|
serializer_class = serializers.TenantSerializer
|
|
filterset_class = filters.TenantFilter
|