diff --git a/geonode/api/resourcebase_api.py b/geonode/api/resourcebase_api.py index e5b28ded6c2..aaab06bf912 100644 --- a/geonode/api/resourcebase_api.py +++ b/geonode/api/resourcebase_api.py @@ -183,6 +183,7 @@ def apply_filters(self, request, applicable_filters): types = applicable_filters.pop('type', None) extent = applicable_filters.pop('extent', None) keywords = applicable_filters.pop('keywords__slug__in', None) + metadata_only = applicable_filters.pop('metadata_only', False) filtering_method = applicable_filters.pop('f_method', 'and') if filtering_method == 'or': filters = Q() @@ -245,7 +246,7 @@ def apply_filters(self, request, applicable_filters): Q(owner__username__iexact=str(user)))) else: filtered = filtered.exclude(Q(dirty_state=True)) - return filtered + return filtered.filter(metadata_only=metadata_only) def filter_published(self, queryset, request): filter_set = get_visible_resources( diff --git a/geonode/api/tests.py b/geonode/api/tests.py index 308be72c81d..16318be17db 100644 --- a/geonode/api/tests.py +++ b/geonode/api/tests.py @@ -421,6 +421,14 @@ def to_date(val): self.assertValidJSONResponse(resp) self.assertEqual(len(self.deserialize(resp)['objects']), 0) + def test_extended_text_filter(self): + """Test that the extended text filter works as expected""" + filter_url = f"{self.list_url}?title__icontains=layer2&abstract__icontains=layer2&purpose__icontains=layer2&f_method=or" + + resp = self.api_client.get(filter_url) + self.assertValidJSONResponse(resp) + self.assertEqual(len(self.deserialize(resp)['objects']), 1) + # noinspection DuplicatedCode @override_settings(API_LOCKDOWN=True)