mirror of https://github.com/jumpserver/jumpserver
perf: 修改 applets related
parent
df14d01859
commit
ba38771d1a
|
@ -4,6 +4,7 @@ from rest_framework.response import Response
|
||||||
|
|
||||||
from common.permissions import IsServiceAccount
|
from common.permissions import IsServiceAccount
|
||||||
from common.drf.api import JMSModelViewSet
|
from common.drf.api import JMSModelViewSet
|
||||||
|
from orgs.utils import tmp_to_builtin_org
|
||||||
from terminal.serializers import (
|
from terminal.serializers import (
|
||||||
AppletHostSerializer, AppletHostDeploymentSerializer,
|
AppletHostSerializer, AppletHostDeploymentSerializer,
|
||||||
AppletHostStartupSerializer
|
AppletHostStartupSerializer
|
||||||
|
@ -19,6 +20,10 @@ class AppletHostViewSet(JMSModelViewSet):
|
||||||
serializer_class = AppletHostSerializer
|
serializer_class = AppletHostSerializer
|
||||||
queryset = AppletHost.objects.all()
|
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):
|
def get_permissions(self):
|
||||||
if self.action == 'startup':
|
if self.action == 'startup':
|
||||||
return [IsServiceAccount()]
|
return [IsServiceAccount()]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.conf import settings
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
@ -27,7 +28,7 @@ class HostMixin:
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_permissions(self):
|
def get_permissions(self):
|
||||||
if self.kwargs.get('host'):
|
if self.kwargs.get('host') and settings.DEBUG:
|
||||||
return [RBACPermission()]
|
return [RBACPermission()]
|
||||||
else:
|
else:
|
||||||
return [IsServiceAccount()]
|
return [IsServiceAccount()]
|
||||||
|
|
|
@ -97,7 +97,7 @@ class AppletHostDeploymentSerializer(serializers.ModelSerializer):
|
||||||
class AppletHostAccountSerializer(serializers.ModelSerializer):
|
class AppletHostAccountSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Account
|
model = Account
|
||||||
fields = ['id', 'username', 'secret', 'date_updated']
|
fields = ['id', 'username', 'secret', 'is_active', 'date_updated']
|
||||||
|
|
||||||
|
|
||||||
class AppletHostAppletReportSerializer(serializers.Serializer):
|
class AppletHostAppletReportSerializer(serializers.Serializer):
|
||||||
|
|
Loading…
Reference in New Issue