mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Move get_filter_fields
to descriptor
This commit is contained in:
parent
1d6562e6ad
commit
aad9289ae9
|
@ -280,9 +280,9 @@ class APIViewSchemaDescriptor(object):
|
|||
fields = self.get_path_fields(path, method)
|
||||
fields += self.get_serializer_fields(path, method)
|
||||
fields += self.get_pagination_fields(path, method)
|
||||
fields += self.get_filter_fields(path, method)
|
||||
|
||||
# TEMP: now we proxy back to the generator
|
||||
fields += generator.get_filter_fields(path, method, view)
|
||||
|
||||
if fields and any([field.location in ('form', 'body') for field in fields]):
|
||||
encoding = generator.get_encoding(path, method, view)
|
||||
|
@ -442,6 +442,19 @@ class APIViewSchemaDescriptor(object):
|
|||
paginator = view.pagination_class()
|
||||
return paginator.get_schema_fields(view)
|
||||
|
||||
def get_filter_fields(self, path, method):
|
||||
view = self.view
|
||||
|
||||
if not is_list_view(path, method, view):
|
||||
return []
|
||||
|
||||
if not getattr(view, 'filter_backends', None):
|
||||
return []
|
||||
|
||||
fields = []
|
||||
for filter_backend in view.filter_backends:
|
||||
fields += filter_backend().get_schema_fields(view)
|
||||
return fields
|
||||
|
||||
# TODO: Where should this live?
|
||||
# - We import APIView here. So we can't import the descriptor into `views`
|
||||
|
@ -650,18 +663,6 @@ class SchemaGenerator(object):
|
|||
|
||||
return None
|
||||
|
||||
def get_filter_fields(self, path, method, view):
|
||||
if not is_list_view(path, method, view):
|
||||
return []
|
||||
|
||||
if not getattr(view, 'filter_backends', None):
|
||||
return []
|
||||
|
||||
fields = []
|
||||
for filter_backend in view.filter_backends:
|
||||
fields += filter_backend().get_schema_fields(view)
|
||||
return fields
|
||||
|
||||
# Method for generating the link layout....
|
||||
|
||||
def get_keys(self, subpath, method, view):
|
||||
|
|
Loading…
Reference in New Issue
Block a user