views.py 678 B

1234567891011121314151617181920212223242526272829303132
  1. from rest_framework.viewsets import ModelViewSet
  2. from tenancy.models import Tenant, TenantGroup
  3. from tenancy.filters import TenantFilter
  4. from extras.api.views import CustomFieldModelViewSet
  5. from . import serializers
  6. #
  7. # Tenant Groups
  8. #
  9. class TenantGroupViewSet(ModelViewSet):
  10. """
  11. List and retrieve tenant groups
  12. """
  13. queryset = TenantGroup.objects.all()
  14. serializer_class = serializers.TenantGroupSerializer
  15. #
  16. # Tenants
  17. #
  18. class TenantViewSet(CustomFieldModelViewSet):
  19. """
  20. List and retrieve tenants
  21. """
  22. queryset = Tenant.objects.select_related('group')
  23. serializer_class = serializers.TenantSerializer
  24. filter_class = TenantFilter