mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-08 10:49:08 +00:00
perf: 资产授权添加协议
This commit is contained in:
@@ -6,4 +6,5 @@ from .label import *
|
||||
from .mixin import *
|
||||
from .node import *
|
||||
from .platform import *
|
||||
from .protocol import *
|
||||
from .tree import *
|
||||
|
@@ -2,8 +2,8 @@ from rest_framework.decorators import action
|
||||
from rest_framework.mixins import ListModelMixin
|
||||
from rest_framework.response import Response
|
||||
|
||||
from assets.const import AllTypes, Protocol
|
||||
from assets.serializers import CategorySerializer, TypeSerializer, ProtocolSerializer
|
||||
from assets.const import AllTypes
|
||||
from assets.serializers import CategorySerializer, TypeSerializer
|
||||
from common.api import JMSGenericViewSet
|
||||
from common.permissions import IsValidUser
|
||||
|
||||
@@ -14,7 +14,6 @@ class CategoryViewSet(ListModelMixin, JMSGenericViewSet):
|
||||
serializer_classes = {
|
||||
'default': CategorySerializer,
|
||||
'types': TypeSerializer,
|
||||
'protocols': ProtocolSerializer,
|
||||
}
|
||||
permission_classes = (IsValidUser,)
|
||||
|
||||
@@ -33,8 +32,3 @@ class CategoryViewSet(ListModelMixin, JMSGenericViewSet):
|
||||
tp = request.query_params.get('type')
|
||||
constraints = AllTypes.get_constraints(category, tp)
|
||||
return Response(constraints)
|
||||
|
||||
@action(methods=['get'], detail=False)
|
||||
def protocols(self, request, *args, **kwargs):
|
||||
protocols = list(Protocol.protocols())
|
||||
return self.get_paginated_response_from_queryset(protocols)
|
||||
|
15
apps/assets/api/protocol.py
Normal file
15
apps/assets/api/protocol.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from rest_framework.generics import ListAPIView
|
||||
|
||||
from assets import serializers
|
||||
from assets.const import Protocol
|
||||
from common.permissions import IsValidUser
|
||||
|
||||
__all__ = ['ProtocolListApi']
|
||||
|
||||
|
||||
class ProtocolListApi(ListAPIView):
|
||||
serializer_class = serializers.ProtocolSerializer
|
||||
permission_classes = (IsValidUser,)
|
||||
|
||||
def get_queryset(self):
|
||||
return list(Protocol.protocols())
|
Reference in New Issue
Block a user