From 3648a1458b81559edcc1cf57c3e4b7a1093fc51f Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 16 Apr 2020 11:27:46 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9command=20options?= =?UTF-8?q?=20get=20view=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/drf/metadata.py | 7 +++---- apps/terminal/api/command.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/common/drf/metadata.py b/apps/common/drf/metadata.py index f29fa0c83..cae11cab3 100644 --- a/apps/common/drf/metadata.py +++ b/apps/common/drf/metadata.py @@ -84,8 +84,7 @@ class SimpleMetadataWithFilters(SimpleMetadata): def get_filters_fields(self, request, view): fields = [] if hasattr(view, 'get_filter_fields'): - # fields = view.get_filter_fields(request) - fields = view.get_filter_fields() + fields = view.get_filter_fields(request) elif hasattr(view, 'filter_fields'): fields = view.filter_fields return fields @@ -93,9 +92,9 @@ class SimpleMetadataWithFilters(SimpleMetadata): def get_ordering_fields(self, request, view): fields = [] if hasattr(view, 'get_ordering_fields'): - fields = view.get_filter_fields(request) + fields = view.get_ordering_fields(request) elif hasattr(view, 'ordering_fields'): - fields = view.filter_fields + fields = view.ordering_fields return fields def determine_metadata(self, request, view): diff --git a/apps/terminal/api/command.py b/apps/terminal/api/command.py index 1bfa122eb..eb0955648 100644 --- a/apps/terminal/api/command.py +++ b/apps/terminal/api/command.py @@ -63,7 +63,7 @@ class CommandQueryMixin: def filter_queryset(self, queryset): return queryset - def get_filter_fields(self): + def get_filter_fields(self, request): fields = self.filter_fields fields.extend(["date_from", "date_to"]) return fields