|
@@ -2,8 +2,12 @@ from django.contrib.auth.models import User, Group
|
|
from rest_framework import viewsets
|
|
from rest_framework import viewsets
|
|
from .serializers import UserSerializer, GroupSerializer
|
|
from .serializers import UserSerializer, GroupSerializer
|
|
from rest_framework.views import APIView
|
|
from rest_framework.views import APIView
|
|
-from .permission import HasAPIKey
|
|
|
|
|
|
+from .permission import HasAPIKey, HAsKeyPermissionn
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework.permissions import IsAuthenticated
|
|
|
|
+from .models import APIKey
|
|
|
|
+from rest_framework.decorators import api_view, permission_classes
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
"""
|
|
"""
|
|
@@ -11,7 +15,10 @@ class UserViewSet(viewsets.ModelViewSet):
|
|
"""
|
|
"""
|
|
queryset = User.objects.all().order_by('-date_joined')
|
|
queryset = User.objects.all().order_by('-date_joined')
|
|
serializer_class = UserSerializer
|
|
serializer_class = UserSerializer
|
|
- permission_classes = [HasAPIKey | IsAuthenticated]
|
|
|
|
|
|
+ keys = APIKey.objects.all()
|
|
|
|
+ for i in keys:
|
|
|
|
+ print()
|
|
|
|
+ permission_classes = [HasAPIKey | IsAuthenticated | HAsKeyPermissionn]
|
|
|
|
|
|
|
|
|
|
class GroupViewSet(viewsets.ModelViewSet):
|
|
class GroupViewSet(viewsets.ModelViewSet):
|