mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-29 21:51:31 +00:00
perf: 资产授权添加协议
This commit is contained in:
@@ -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
|
||||
from assets.serializers import CategorySerializer, TypeSerializer
|
||||
from assets.const import AllTypes, Protocol
|
||||
from assets.serializers import CategorySerializer, TypeSerializer, ProtocolSerializer
|
||||
from common.api import JMSGenericViewSet
|
||||
from common.permissions import IsValidUser
|
||||
|
||||
@@ -13,7 +13,8 @@ __all__ = ['CategoryViewSet']
|
||||
class CategoryViewSet(ListModelMixin, JMSGenericViewSet):
|
||||
serializer_classes = {
|
||||
'default': CategorySerializer,
|
||||
'types': TypeSerializer
|
||||
'types': TypeSerializer,
|
||||
'protocols': ProtocolSerializer,
|
||||
}
|
||||
permission_classes = (IsValidUser,)
|
||||
|
||||
@@ -32,3 +33,8 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user