Skip to content

Commit

Permalink
[Fixes GeoNode#7236] Issues with layer style legends displayed when m…
Browse files Browse the repository at this point in the history
…ore than one style is selected (GeoNode#7253) (GeoNode#7256)

Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
marthamareal and Alessio Fabiani committed May 18, 2021
1 parent 43ecdeb commit 23d2ad7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,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
10 changes: 5 additions & 5 deletions geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,14 @@ 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 \
not re.match(temp_style_name_regex, _style_name):
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':
logger.debug(
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 @@ -590,7 +590,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 @@ -607,6 +608,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 23d2ad7

Please sign in to comment.