diff --git a/geonode/api/resourcebase_api.py b/geonode/api/resourcebase_api.py index 0108c4eb4f4..8ad07aa0557 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() @@ -235,7 +236,7 @@ def apply_filters(self, request, applicable_filters): return get_visible_resources( filtered, request.user if request else None, - metadata_only=applicable_filters.get('metadata_only', False), + metadata_only=metadata_only, admin_approval_required=settings.ADMIN_MODERATE_UPLOADS, unpublished_not_visible=settings.RESOURCE_PUBLISHING, private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES) diff --git a/geonode/api/tests.py b/geonode/api/tests.py index 2536473ed6a..d618190135f 100644 --- a/geonode/api/tests.py +++ b/geonode/api/tests.py @@ -430,6 +430,14 @@ def to_date(val): self.assertValidJSONResponse(resp) self.assertEqual(len(self.deserialize(resp)['objects']), 4) + 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) diff --git a/geonode/geoserver/helpers.py b/geonode/geoserver/helpers.py index d4ea1a88f7e..0f156b61b46 100755 --- a/geonode/geoserver/helpers.py +++ b/geonode/geoserver/helpers.py @@ -1151,7 +1151,7 @@ def save_style(gs_style, layer): try: style, created = Style.objects.get_or_create(name=style_name) style.workspace = gs_style.workspace - style.sld_title = gs_style.sld_title if gs_style.style_format != 'css' else sld_name + style.sld_title = gs_style.sld_title if gs_style.style_format != 'css' and gs_style.sld_title else sld_name style.sld_body = gs_style.sld_body style.sld_url = gs_style.body_href style.save() diff --git a/geonode/geoserver/views.py b/geonode/geoserver/views.py index 306365923f2..ff150f0eeb8 100644 --- a/geonode/geoserver/views.py +++ b/geonode/geoserver/views.py @@ -526,13 +526,13 @@ def strip_prefix(path, prefix): logger.debug( f"[geoserver_proxy] Updating Style ---> url {url.geturl()}") _style_name, _style_ext = os.path.splitext(os.path.basename(urlsplit(url.geturl()).path)) + _parsed_get_args = dict(parse_qsl(urlsplit(url.geturl()).query)) if _style_name == 'styles.json' and request.method == "PUT": - _parsed_get_args = dict(parse_qsl(urlsplit(url.geturl()).query)) - if 'name' in _parsed_get_args: - _style_name, _style_ext = os.path.splitext(_parsed_get_args['name']) + if _parsed_get_args.get('name'): + _style_name, _style_ext = os.path.splitext(_parsed_get_args.get('name')) else: _style_name, _style_ext = os.path.splitext(_style_name) - if _style_name != 'style-check' and _style_ext == '.json' and \ + if _style_name != 'style-check' and (_style_ext == '.json' or _parsed_get_args.get('raw')) and \ not re.match(temp_style_name_regex, _style_name): affected_layers = style_update(request, raw_url) elif downstream_path == 'rest/layers': diff --git a/geonode/layers/templates/layers/layer_detail.html b/geonode/layers/templates/layers/layer_detail.html index 591cab60f07..7c66242e0df 100644 --- a/geonode/layers/templates/layers/layer_detail.html +++ b/geonode/layers/templates/layers/layer_detail.html @@ -589,7 +589,8 @@

{%trans "Legend" %}

{% if resource.default_style %} {% get_all_resource_styles resource as resource_styles_all%} {% for style in resource_styles_all %} - {% if resource.default_style == style or resource.default_style.name == style.name or resource.default_style.sld_title == style.sld_title %} + {% if style.name or style.sld_title %} + {% if resource.default_style == style or resource.default_style.name == style.name or style.sld_title and resource.default_style.sld_title == style.sld_title %} {% for legend in resource.get_legend %} {% get_sld_name_from_url style.sld_url as sld_name %} {% with "STYLE="|add:sld_name as style_name %} @@ -606,6 +607,7 @@

{%trans "Legend" %}

{% endwith %} {% endfor %} {% endif %} + {% endif %} {% endfor %} {% else %} {% for legend in resource.get_legend %}