Skip to content

Commit

Permalink
添加重要API信息记录以及QRCode验证
Browse files Browse the repository at this point in the history
  • Loading branch information
YoLoveLife committed Jul 9, 2018
1 parent 4663181 commit e4621e3
Show file tree
Hide file tree
Showing 60 changed files with 3,377 additions and 3,296 deletions.
163 changes: 80 additions & 83 deletions apps/authority/api/jumper.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,80 @@
# -*- coding:utf-8 -*-
from .. import models,serializers,filter
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated,AllowAny
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.views import Response, status
from rest_framework.pagination import PageNumberPagination
from authority.permission import jumper as JumperPermission
from deveops.api import WebTokenAuthentication


__all__ = [
"JumperListAPI", "JumperCreateAPI", "JumperUpdateAPI",
"JumperDeleteAPI", 'JumperPagination', 'JumperListByPageAPI',
]


class JumperPagination(PageNumberPagination):
page_size = 10


class JumperListAPI(WebTokenAuthentication, generics.ListAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperListRequiredMixin, IsAuthenticated]
filter_class = filter.JumperFilter


class JumperListByPageAPI(WebTokenAuthentication, generics.ListAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperListRequiredMixin, IsAuthenticated]
pagination_class = JumperPagination
filter_class = filter.JumperFilter


class JumperStatusAPI(WebTokenAuthentication, generics.ListAPIView):
serializer_class = serializers.JumperSerializer
permission_classes = [JumperPermission.JumperStatusRequiredMixin, IsAuthenticated]

def get_object(self):
return models.Jumper.objects.filter(uuid=self.kwargs['pk']).get()

def get(self, request, *args, **kwargs):
obj = self.get_object()
obj.check_status()
obj.save()
return Response({'detail': '刷新成功'}, status=status.HTTP_200_OK)


class JumperCreateAPI(WebTokenAuthentication, generics.CreateAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
permission_classes = [JumperPermission.JumperCreateRequiredMixin, IsAuthenticated]


class JumperUpdateAPI(WebTokenAuthentication, generics.UpdateAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperUpdateRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'


class JumperDeleteAPI(WebTokenAuthentication,generics.DestroyAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperDeleteRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'

def delete(self, request, *args, **kwargs):
jumper = self.get_object()
# jumper = models.Jumper.objects.get(id=int(kwargs['pk']))
try:
group = jumper.group
return Response({'detail': u'该密钥属于应用组' + group.name + u'无法删除'}, status=status.HTTP_406_NOT_ACCEPTABLE)
except ObjectDoesNotExist:
return super(JumperDeleteAPI,self).delete(request,*args,**kwargs)
# -*- coding:utf-8 -*-
from .. import models,serializers,filter
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated,AllowAny
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.views import Response, status
from rest_framework.pagination import PageNumberPagination
from authority.permission import jumper as JumperPermission
from deveops.api import WebTokenAuthentication
from rest_framework.views import APIView

__all__ = [
"JumperListAPI", "JumperCreateAPI", "JumperUpdateAPI",
"JumperDeleteAPI", 'JumperPagination', 'JumperListByPageAPI',
]


class JumperPagination(PageNumberPagination):
page_size = 10


class JumperListAPI(WebTokenAuthentication, generics.ListAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperListRequiredMixin, IsAuthenticated]
filter_class = filter.JumperFilter


class JumperListByPageAPI(WebTokenAuthentication, generics.ListAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperListRequiredMixin, IsAuthenticated]
pagination_class = JumperPagination
filter_class = filter.JumperFilter


class JumperStatusAPI(WebTokenAuthentication, APIView):
permission_classes = [JumperPermission.JumperStatusRequiredMixin, IsAuthenticated]

def get_object(self):
return models.Jumper.objects.filter(uuid=self.kwargs['pk']).get()

def get(self, request, *args, **kwargs):
obj = self.get_object()
obj.check_status()
return Response({'detail': '刷新成功'}, status=status.HTTP_200_OK)


class JumperCreateAPI(WebTokenAuthentication, generics.CreateAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
permission_classes = [JumperPermission.JumperCreateRequiredMixin, IsAuthenticated]


class JumperUpdateAPI(WebTokenAuthentication, generics.UpdateAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperUpdateRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'


class JumperDeleteAPI(WebTokenAuthentication,generics.DestroyAPIView):
module = models.Jumper
serializer_class = serializers.JumperSerializer
queryset = models.Jumper.objects.all()
permission_classes = [JumperPermission.JumperDeleteRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'

def delete(self, request, *args, **kwargs):
jumper = self.get_object()
try:
group = jumper.group
return Response({'detail': u'该密钥属于应用组' + group.name + u'无法删除'}, status=status.HTTP_406_NOT_ACCEPTABLE)
except ObjectDoesNotExist:
return super(JumperDeleteAPI,self).delete(request,*args,**kwargs)
136 changes: 68 additions & 68 deletions apps/authority/api/key.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
# -*- coding:utf-8 -*-
from .. import models,serializers,filter
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated,AllowAny
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.views import Response, status
from rest_framework.pagination import PageNumberPagination
from authority.permission import key as KeyPermission
from deveops.api import WebTokenAuthentication


__all__ = [
"KeyListAPI", "KeyCreateAPI", "KeyUpdateAPI",
"KeyDeleteAPI", 'KeyPagination', 'KeyListByPage'
]


class KeyPagination(PageNumberPagination):
page_size = 10


class KeyListAPI(WebTokenAuthentication,generics.ListAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyListRequiredMixin, IsAuthenticated]
filter_class = filter.KeyFilter


class KeyListByPageAPI(WebTokenAuthentication,generics.ListAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyListRequiredMixin, IsAuthenticated]
pagination_class = KeyPagination
filter_class = filter.KeyFilter


class KeyCreateAPI(WebTokenAuthentication,generics.CreateAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
permission_classes = [KeyPermission.KeyCreateRequiredMixin, IsAuthenticated]


class KeyUpdateAPI(WebTokenAuthentication,generics.UpdateAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyUpdateRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'


class KeyDeleteAPI(WebTokenAuthentication,generics.DestroyAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyDeleteRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'

def delete(self, request, *args, **kwargs):
key = self.get_object()
try:
group = key.group
return Response({'detail': u'该密钥属于应用组'+group.name+u'无法删除'}, status=status.HTTP_406_NOT_ACCEPTABLE)
except ObjectDoesNotExist:
return super(KeyDeleteAPI,self).delete(request,*args,**kwargs)
# -*- coding:utf-8 -*-
from .. import models,serializers,filter
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated,AllowAny
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.views import Response, status
from rest_framework.pagination import PageNumberPagination
from authority.permission import key as KeyPermission
from deveops.api import WebTokenAuthentication


__all__ = [
"KeyListAPI", "KeyCreateAPI", "KeyUpdateAPI",
"KeyDeleteAPI", 'KeyPagination', 'KeyListByPageAPI'
]


class KeyPagination(PageNumberPagination):
page_size = 10


class KeyListAPI(WebTokenAuthentication,generics.ListAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyListRequiredMixin, IsAuthenticated]
filter_class = filter.KeyFilter


class KeyListByPageAPI(WebTokenAuthentication,generics.ListAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyListRequiredMixin, IsAuthenticated]
pagination_class = KeyPagination
filter_class = filter.KeyFilter


class KeyCreateAPI(WebTokenAuthentication,generics.CreateAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
permission_classes = [KeyPermission.KeyCreateRequiredMixin, IsAuthenticated]


class KeyUpdateAPI(WebTokenAuthentication,generics.UpdateAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyUpdateRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'


class KeyDeleteAPI(WebTokenAuthentication,generics.DestroyAPIView):
module = models.Key
serializer_class = serializers.KeySerializer
queryset = models.Key.objects.all()
permission_classes = [KeyPermission.KeyDeleteRequiredMixin, IsAuthenticated]
lookup_field = 'uuid'
lookup_url_kwarg = 'pk'

def delete(self, request, *args, **kwargs):
key = self.get_object()
try:
group = key.group
return Response({'detail': u'该密钥属于应用组'+group.name+u'无法删除'}, status=status.HTTP_406_NOT_ACCEPTABLE)
except ObjectDoesNotExist:
return super(KeyDeleteAPI,self).delete(request,*args,**kwargs)
Loading

0 comments on commit e4621e3

Please sign in to comment.