perf: 去掉 v2 的api

This commit is contained in:
ibuler
2021-01-20 18:33:38 +08:00
committed by Jiangjie.Bai
parent d363118911
commit dd5b2b9101
20 changed files with 285 additions and 420 deletions

View File

@@ -5,18 +5,22 @@ import uuid
from django.core.cache import cache
from django.shortcuts import get_object_or_404
from rest_framework import viewsets
from rest_framework import viewsets, generics
from rest_framework.views import APIView, Response
from rest_framework import status
from django.conf import settings
from common.drf.api import JMSBulkModelViewSet
from common.utils import get_object_or_none
from common.permissions import IsAppUser, IsOrgAdminOrAppUser, IsSuperUser
from common.permissions import IsAppUser, IsOrgAdminOrAppUser, IsSuperUser, WithBootstrapToken
from ..models import Terminal, Status, Session
from .. import serializers
from .. import exceptions
__all__ = [
'TerminalViewSet', 'StatusViewSet', 'TerminalConfig',
'TerminalRegistrationApi',
]
logger = logging.getLogger(__file__)
@@ -112,4 +116,16 @@ class TerminalConfig(APIView):
def get(self, request):
config = request.user.terminal.config
return Response(config, status=200)
return Response(config, status=200)
class TerminalRegistrationApi(generics.CreateAPIView):
serializer_class = serializers.TerminalRegistrationSerializer
permission_classes = [WithBootstrapToken]
http_method_names = ['post']
def create(self, request, *args, **kwargs):
if not settings.SECURITY_SERVICE_ACCOUNT_REGISTRATION:
data = {"error": "service account registration disabled"}
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
return super().create(request, *args, **kwargs)