|
@@ -5,8 +5,9 @@ from rest_framework.views import APIView
|
|
from .permission import HasAPIKey
|
|
from .permission import HasAPIKey
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from .models import APIKey
|
|
from .models import APIKey
|
|
-from rest_framework.decorators import api_view, permission_classes
|
|
|
|
from rest_framework.response import Response
|
|
from rest_framework.response import Response
|
|
|
|
+from django.utils.decorators import method_decorator
|
|
|
|
+from .decorators import api_permission_required
|
|
|
|
|
|
|
|
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
@@ -32,7 +33,8 @@ class GroupViewSet(viewsets.ModelViewSet):
|
|
|
|
|
|
class SnippetUSER(APIView):
|
|
class SnippetUSER(APIView):
|
|
permission_classes = []
|
|
permission_classes = []
|
|
- print(permission_classes)
|
|
|
|
|
|
+
|
|
|
|
+ @method_decorator(api_permission_required("user", "post"), name='dispatch')
|
|
def get(self, request, format=None):
|
|
def get(self, request, format=None):
|
|
snippets = User.objects.all()
|
|
snippets = User.objects.all()
|
|
serializer = UserSerializer(snippets, many=True, context={'request': request})
|
|
serializer = UserSerializer(snippets, many=True, context={'request': request})
|