mirror of https://github.com/jumpserver/jumpserver
perf: 优化所有资源列表的默认排序规则
parent
3336a4526b
commit
681cecc52b
|
@ -214,3 +214,11 @@ class CommonApiMixin(
|
||||||
def is_swagger_request(self):
|
def is_swagger_request(self):
|
||||||
return getattr(self, 'swagger_fake_view', False) or \
|
return getattr(self, 'swagger_fake_view', False) or \
|
||||||
getattr(self, 'raw_action', '') == 'metadata'
|
getattr(self, 'raw_action', '') == 'metadata'
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
queryset = super().get_queryset()
|
||||||
|
|
||||||
|
if 'name' in self.ordering_fields:
|
||||||
|
self.ordering = ('name',)
|
||||||
|
|
||||||
|
return queryset
|
||||||
|
|
|
@ -37,6 +37,7 @@ class BaseStorageViewSetMixin:
|
||||||
|
|
||||||
class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
||||||
search_fields = ('name', 'type')
|
search_fields = ('name', 'type')
|
||||||
|
ordering = ('name',)
|
||||||
queryset = CommandStorage.objects.all()
|
queryset = CommandStorage.objects.all()
|
||||||
serializer_class = CommandStorageSerializer
|
serializer_class = CommandStorageSerializer
|
||||||
filterset_class = CommandStorageFilter
|
filterset_class = CommandStorageFilter
|
||||||
|
@ -114,6 +115,7 @@ class ReplayStorageFilterSet(BaseFilterSet):
|
||||||
|
|
||||||
class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
||||||
search_fields = ('name', 'type', 'is_default')
|
search_fields = ('name', 'type', 'is_default')
|
||||||
|
ordering = ('name',)
|
||||||
queryset = ReplayStorage.objects.all()
|
queryset = ReplayStorage.objects.all()
|
||||||
serializer_class = ReplayStorageSerializer
|
serializer_class = ReplayStorageSerializer
|
||||||
filterset_class = ReplayStorageFilterSet
|
filterset_class = ReplayStorageFilterSet
|
||||||
|
|
Loading…
Reference in New Issue