forked from YoLoveLife/DevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4663181
commit e4621e3
Showing
60 changed files
with
3,377 additions
and
3,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.