Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GeoNode/geonode into ISSU…
Browse files Browse the repository at this point in the history
…E_7154

# Conflicts:
#	geonode/api/resourcebase_api.py
  • Loading branch information
afabiani committed Apr 8, 2021
2 parents 343a629 + abdf3ed commit d146965
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions geonode/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
4 changes: 3 additions & 1 deletion geonode/layers/templates/layers/layer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ <h4 class="list-group-item-heading">{%trans "Legend" %}</h4>
{% 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 %}
Expand All @@ -606,6 +607,7 @@ <h4 class="list-group-item-heading">{%trans "Legend" %}</h4>
{% endwith %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% else %}
{% for legend in resource.get_legend %}
Expand Down

0 comments on commit d146965

Please sign in to comment.