2017-05-24 11:33:11 -04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from extras.api.views import CustomFieldModelViewSet
|
2017-06-19 16:10:18 -04:00
|
|
|
from tenancy import filters
|
2016-07-26 14:58:37 -04:00
|
|
|
from tenancy.models import Tenant, TenantGroup
|
2017-11-07 15:36:10 -05:00
|
|
|
from utilities.api import FieldChoicesViewSet, ModelViewSet
|
2016-07-26 14:58:37 -04:00
|
|
|
from . import serializers
|
|
|
|
|
|
|
|
|
2017-10-10 16:41:35 -04:00
|
|
|
#
|
|
|
|
# Field choices
|
|
|
|
#
|
|
|
|
|
|
|
|
class TenancyFieldChoicesViewSet(FieldChoicesViewSet):
|
|
|
|
fields = ()
|
|
|
|
|
|
|
|
|
2017-01-24 17:12:16 -05:00
|
|
|
#
|
|
|
|
# Tenant Groups
|
|
|
|
#
|
2016-07-26 14:58:37 -04:00
|
|
|
|
2017-01-24 17:12:16 -05:00
|
|
|
class TenantGroupViewSet(ModelViewSet):
|
2016-07-26 14:58:37 -04:00
|
|
|
queryset = TenantGroup.objects.all()
|
|
|
|
serializer_class = serializers.TenantGroupSerializer
|
2017-06-19 16:10:18 -04:00
|
|
|
filter_class = filters.TenantGroupFilter
|
2016-07-26 14:58:37 -04:00
|
|
|
|
|
|
|
|
2017-01-24 17:12:16 -05:00
|
|
|
#
|
|
|
|
# Tenants
|
|
|
|
#
|
2016-07-26 14:58:37 -04:00
|
|
|
|
2017-11-07 15:36:10 -05:00
|
|
|
class TenantViewSet(CustomFieldModelViewSet):
|
2017-01-24 17:12:16 -05:00
|
|
|
queryset = Tenant.objects.select_related('group')
|
2016-07-26 14:58:37 -04:00
|
|
|
serializer_class = serializers.TenantSerializer
|
2017-06-19 16:10:18 -04:00
|
|
|
filter_class = filters.TenantFilter
|