mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-31 15:11:27 +00:00
perf(api): filter_fields被filterset_fields取代
https://django-filter.readthedocs.io/en/stable/guide/migration.html
This commit is contained in:
@@ -28,7 +28,7 @@ __all__ = ['CommandViewSet', 'CommandExportApi', 'InsecureCommandAlertAPI']
|
||||
class CommandQueryMixin:
|
||||
command_store = get_command_storage()
|
||||
permission_classes = [IsOrgAdminOrAppUser | IsOrgAuditor]
|
||||
filter_fields = [
|
||||
filterset_fields = [
|
||||
"asset", "system_user", "user", "session", "risk_level",
|
||||
"input"
|
||||
]
|
||||
|
@@ -42,7 +42,7 @@ class SessionViewSet(OrgBulkModelViewSet):
|
||||
'display': serializers.SessionDisplaySerializer,
|
||||
}
|
||||
permission_classes = (IsOrgAdminOrAppUser, )
|
||||
filter_fields = [
|
||||
filterset_fields = [
|
||||
"user", "asset", "system_user", "remote_addr",
|
||||
"protocol", "terminal", "is_finished", 'login_from',
|
||||
]
|
||||
|
@@ -30,16 +30,16 @@ class BaseStorageViewSetMixin:
|
||||
|
||||
|
||||
class CommandStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
||||
filter_fields = ('name', 'type',)
|
||||
search_fields = filter_fields
|
||||
filterset_fields = ('name', 'type',)
|
||||
search_fields = filterset_fields
|
||||
queryset = CommandStorage.objects.all()
|
||||
serializer_class = CommandStorageSerializer
|
||||
permission_classes = (IsSuperUser,)
|
||||
|
||||
|
||||
class ReplayStorageViewSet(BaseStorageViewSetMixin, viewsets.ModelViewSet):
|
||||
filter_fields = ('name', 'type',)
|
||||
search_fields = filter_fields
|
||||
filterset_fields = ('name', 'type',)
|
||||
search_fields = filterset_fields
|
||||
queryset = ReplayStorage.objects.all()
|
||||
serializer_class = ReplayStorageSerializer
|
||||
permission_classes = (IsSuperUser,)
|
||||
|
@@ -27,7 +27,7 @@ class TerminalViewSet(JMSBulkModelViewSet):
|
||||
queryset = Terminal.objects.filter(is_deleted=False)
|
||||
serializer_class = serializers.TerminalSerializer
|
||||
permission_classes = (IsSuperUser,)
|
||||
filter_fields = ['name', 'remote_addr', 'type']
|
||||
filterset_fields = ['name', 'remote_addr', 'type']
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
if isinstance(request.data, list):
|
||||
|
Reference in New Issue
Block a user