|
@@ -9,9 +9,18 @@ from core.permissions import IsOwnerOrReadOnly |
|
|
from users.models import User |
|
|
from users.models import User |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserViewSet(mixins.RetrieveModelMixin, GenericViewSet): |
|
|
|
|
|
queryset = User.objects.all() |
|
|
|
|
|
|
|
|
class UserViewSet( |
|
|
|
|
|
mixins.RetrieveModelMixin, |
|
|
|
|
|
mixins.ListModelMixin, |
|
|
|
|
|
GenericViewSet, |
|
|
|
|
|
): |
|
|
serializer_class = api.UserSerializer |
|
|
serializer_class = api.UserSerializer |
|
|
|
|
|
pagination_class = None |
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
|
if self.request.user.is_anonymous: |
|
|
|
|
|
return User.objects.none() |
|
|
|
|
|
return User.objects.filter(id=self.request.user.id) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageViewSet(mixins.CreateModelMixin, GenericViewSet): |
|
|
class ImageViewSet(mixins.CreateModelMixin, GenericViewSet): |
|
@@ -43,7 +52,7 @@ class BoardViewSet(viewsets.ModelViewSet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drf_router = routers.DefaultRouter() |
|
|
drf_router = routers.DefaultRouter() |
|
|
drf_router.register(r'users', UserViewSet) |
|
|
|
|
|
|
|
|
drf_router.register(r'users', UserViewSet, base_name="user") |
|
|
drf_router.register(r'pins', PinViewSet) |
|
|
drf_router.register(r'pins', PinViewSet) |
|
|
drf_router.register(r'images', ImageViewSet) |
|
|
drf_router.register(r'images', ImageViewSet) |
|
|
drf_router.register(r'boards', BoardViewSet) |
|
|
drf_router.register(r'boards', BoardViewSet) |