Skip to content

Commit

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

Co-authored-by: Alessio Fabiani <[email protected]>
  • Loading branch information
github-actions[bot] and Alessio Fabiani authored Apr 8, 2021
1 parent 2d940ad commit 7be9733
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,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 @@ -593,7 +593,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 @@ -610,6 +611,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 7be9733

Please sign in to comment.