perf(api): filter_fields被filterset_fields取代

https://django-filter.readthedocs.io/en/stable/guide/migration.html
This commit is contained in:
ibuler
2021-01-07 10:53:10 +08:00
committed by Jiangjie.Bai
parent ff4748f9f4
commit e7a3c5a822
33 changed files with 88 additions and 85 deletions

View File

@@ -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"
]

View File

@@ -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',
]

View File

@@ -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,)

View File

@@ -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):