perf: 优化 一些继承

pull/9631/head
ibuler 2023-02-20 13:36:50 +08:00
parent 492dd34cb8
commit 4818e759bc
3 changed files with 15 additions and 13 deletions

View File

@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
#
from django.utils.translation import ugettext as _
from django.conf import settings
from rest_framework_bulk import BulkModelViewSet
from rest_framework.generics import RetrieveAPIView
from django.utils.translation import ugettext as _
from rest_framework.exceptions import PermissionDenied
from rest_framework.generics import RetrieveAPIView
from common.utils import get_logger
from common.permissions import IsValidUser
from users.models import User, UserGroup
from assets.models import (
Asset, Domain, Label, Node,
)
from perms.models import AssetPermission
from common.api import JMSBulkModelViewSet
from common.permissions import IsValidUser
from common.utils import get_logger
from orgs.utils import current_org, tmp_to_root_org
from perms.models import AssetPermission
from users.models import User, UserGroup
from .models import Organization
from .serializers import (
OrgSerializer, CurrentOrgSerializer
@ -29,7 +29,7 @@ org_related_models = [
]
class OrgViewSet(BulkModelViewSet):
class OrgViewSet(JMSBulkModelViewSet):
filterset_fields = ('name',)
search_fields = ('name', 'comment')
queryset = Organization.objects.all()

View File

@ -26,6 +26,7 @@ logger = get_logger(__name__)
class BaseUserPermedAssetsApi(SelfOrPKUserMixin, ListAPIView):
ordering = ('name',)
search_fields = ('name', 'address', 'comment')
ordering_fields = ("name", "address")
filterset_class = AssetFilterSet
serializer_class = serializers.AssetPermedSerializer
only_fields = serializers.AssetPermedSerializer.Meta.only_fields

View File

@ -1,22 +1,23 @@
# -*- coding: utf-8 -*-
#
import logging
from rest_framework.views import APIView, Response
from rest_framework_bulk import BulkModelViewSet
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView, Response
from common.api import JMSBulkModelViewSet
from common.utils import get_object_or_none
from orgs.utils import tmp_to_root_org
from terminal.models import Session, Task
from terminal import serializers
from terminal.models import Session, Task
from terminal.utils import is_session_approver
__all__ = ['TaskViewSet', 'KillSessionAPI', 'KillSessionForTicketAPI']
logger = logging.getLogger(__file__)
class TaskViewSet(BulkModelViewSet):
class TaskViewSet(JMSBulkModelViewSet):
queryset = Task.objects.all()
serializer_class = serializers.TaskSerializer
filterset_fields = ('is_finished',)
@ -51,7 +52,7 @@ class KillSessionAPI(APIView):
class KillSessionForTicketAPI(APIView):
permission_classes = (IsAuthenticated, )
permission_classes = (IsAuthenticated,)
def post(self, request, *args, **kwargs):
session_ids = request.data