Browse Source

fix: 对象存储下拉无法自动加载

pull/12121/head
wangruidong 1 year ago committed by 老广
parent
commit
7a5cffac91
  1. 14
      apps/terminal/api/component/storage.py

14
apps/terminal/api/component/storage.py

@ -3,12 +3,14 @@
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django_filters import utils from django_filters import utils
from django_filters import rest_framework as drf_filters
from rest_framework import viewsets, generics, status from rest_framework import viewsets, generics, status
from rest_framework.decorators import action from rest_framework.decorators import action
from rest_framework.request import Request from rest_framework.request import Request
from rest_framework.response import Response from rest_framework.response import Response
from common.const.http import GET from common.const.http import GET
from common.drf.filters import BaseFilterSet
from terminal import const from terminal import const
from terminal.filters import CommandStorageFilter, CommandFilter, CommandFilterForStorageTree from terminal.filters import CommandStorageFilter, CommandFilter, CommandFilterForStorageTree
from terminal.models import CommandStorage, ReplayStorage from terminal.models import CommandStorage, ReplayStorage
@ -102,11 +104,19 @@ class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
return Response(data=nodes) return Response(data=nodes)
class ReplayStorageFilterSet(BaseFilterSet):
type_not = drf_filters.CharFilter(field_name='type', exclude=True)
class Meta:
model = ReplayStorage
fields = ['name', 'type', 'is_default', 'type_not']
class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet): class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
filterset_fields = ('name', 'type', 'is_default') search_fields = ('name', 'type', 'is_default')
search_fields = filterset_fields
queryset = ReplayStorage.objects.all() queryset = ReplayStorage.objects.all()
serializer_class = ReplayStorageSerializer serializer_class = ReplayStorageSerializer
filterset_class = ReplayStorageFilterSet
class BaseStorageTestConnectiveMixin: class BaseStorageTestConnectiveMixin:

Loading…
Cancel
Save