mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-31 15:11:27 +00:00
fix: 有在线会话的终端不能删除
This commit is contained in:
@@ -8,8 +8,9 @@ from rest_framework import generics
|
||||
from rest_framework.views import APIView, Response
|
||||
from rest_framework import status
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
from common.exceptions import JMSException
|
||||
from common.drf.api import JMSBulkModelViewSet
|
||||
from common.utils import get_object_or_none
|
||||
from common.permissions import IsAppUser, IsSuperUser, WithBootstrapToken
|
||||
@@ -30,6 +31,17 @@ class TerminalViewSet(JMSBulkModelViewSet):
|
||||
permission_classes = (IsSuperUser,)
|
||||
filterset_fields = ['name', 'remote_addr', 'type']
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
if instance.get_online_session_count() > 0:
|
||||
raise JMSException(
|
||||
code='have_online_session',
|
||||
detail=_('Have online sessions')
|
||||
)
|
||||
|
||||
self.perform_destroy(instance)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
if isinstance(request.data, list):
|
||||
raise exceptions.BulkCreateNotSupport()
|
||||
|
Reference in New Issue
Block a user