perf: 修改 applets related

pull/9029/head
ibuler 2022-11-08 13:55:06 +08:00
parent df14d01859
commit ba38771d1a
3 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,7 @@ from rest_framework.response import Response
from common.permissions import IsServiceAccount
from common.drf.api import JMSModelViewSet
from orgs.utils import tmp_to_builtin_org
from terminal.serializers import (
AppletHostSerializer, AppletHostDeploymentSerializer,
AppletHostStartupSerializer
@ -19,6 +20,10 @@ class AppletHostViewSet(JMSModelViewSet):
serializer_class = AppletHostSerializer
queryset = AppletHost.objects.all()
def dispatch(self, request, *args, **kwargs):
with tmp_to_builtin_org(system=1):
return super().dispatch(request, *args, **kwargs)
def get_permissions(self):
if self.action == 'startup':
return [IsServiceAccount()]

View File

@ -1,6 +1,7 @@
from typing import Callable
from django.shortcuts import get_object_or_404
from django.conf import settings
from rest_framework.request import Request
from rest_framework.decorators import action
from rest_framework.response import Response
@ -27,7 +28,7 @@ class HostMixin:
)
def get_permissions(self):
if self.kwargs.get('host'):
if self.kwargs.get('host') and settings.DEBUG:
return [RBACPermission()]
else:
return [IsServiceAccount()]

View File

@ -97,7 +97,7 @@ class AppletHostDeploymentSerializer(serializers.ModelSerializer):
class AppletHostAccountSerializer(serializers.ModelSerializer):
class Meta:
model = Account
fields = ['id', 'username', 'secret', 'date_updated']
fields = ['id', 'username', 'secret', 'is_active', 'date_updated']
class AppletHostAppletReportSerializer(serializers.Serializer):