mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-24 21:08:30 +00:00
pref: 修改 applet host
This commit is contained in:
@@ -1,26 +1,20 @@
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from orgs.utils import tmp_to_root_org
|
||||
from orgs.models import Organization
|
||||
from assets.models import Host
|
||||
from orgs.utils import tmp_to_builtin_org
|
||||
from terminal import serializers, models
|
||||
|
||||
__all__ = ['AppletHostViewSet', 'AppletHostDeploymentViewSet']
|
||||
|
||||
|
||||
class AppletHostViewSet(viewsets.ModelViewSet):
|
||||
queryset = models.AppletHost.objects.all()
|
||||
serializer_class = serializers.AppletHostSerializer
|
||||
|
||||
@action(methods=['get'], detail=False)
|
||||
def hosts(self, request):
|
||||
with tmp_to_root_org():
|
||||
kwargs = {
|
||||
'platform__name': 'RemoteAppHost',
|
||||
'org_id': Organization.SYSTEM_ID
|
||||
}
|
||||
return Host.objects.filter(**kwargs)
|
||||
def get_queryset(self):
|
||||
return models.AppletHost.objects.all()
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
with tmp_to_builtin_org(system=1):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class AppletHostDeploymentViewSet(viewsets.ModelViewSet):
|
||||
|
Reference in New Issue
Block a user