text: """Circle views."""
  
  # Django REST Framework
  from rest_framework import viewsets
  
  # Permissions
  from cride.circles.permissions import IsCircleAdmin
  from rest_framework.permissions import IsAuthenticated
  from rest_framework.exceptions import MethodNotAllowed
  
  # Serializers
  from cride.circles.serializers import CircleModelSerializer
  
  # Models
  from cride.circles.models import Circle, Membership
  
  
  class CircleViewSet(viewsets.ModelViewSet):
      """Circle view set."""
  
      serializer_class = CircleModelSerializer
      lookup_field = 'slug_name'
  
      def get_queryset(self):
          """Restrict list to public-only."""
          queryset = Circle.objects.all()
          if self.action == 'list':
              return queryset.filter(is_public=True)
          return queryset
      
      def get_permissions(self):
          """Assign permissions based on action."""
          permissions = [IsAuthenticated]
          if self.action in ['update', 'partial_update']:
              permissions.append(IsCircleAdmin)
          return [permission() for permission in permissions]
  
      def perform_create(self, serializer):
          """Assign circle admin."""
          circle = serializer.save()
          user = self.request.user
          profile = user.profile
          Membership.objects.create(
              user=user,
              profile=user.profile,
              circle=circle,
              is_admin=True,
              remaining_invitations=10
          )
      
      def destroy(self, request, pk=None):
          raise MethodNotAllowed('DELETE')