Skip to content

Commit

Permalink
- Fix the way how to Style Manage page fetches the styles: read them…
Browse files Browse the repository at this point in the history
… from GeoNode and align with the GeoServer instance
  • Loading branch information
afabiani committed Nov 28, 2018
1 parent 9059412 commit ea3ed73
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,21 @@ def layer_style_manage(request, layername):
logger.warn(
'Unable to set the default style. Ensure Geoserver is running and that this layer exists.')

# Ahmed Nour:
# Get public styles also
all_available_gs_styles = cat.get_styles(
settings.DEFAULT_WORKSPACE)
all_available_gs_styles += cat.get_styles()
gs_styles = []
for style in all_available_gs_styles:
for style in Style.objects.all():
sld_title = style.name
if style.sld_title:
sld_title = style.sld_title
try:
if style.sld_title:
sld_title = style.sld_title
gs_sld = cat.get_style(style.name,
workspace=settings.DEFAULT_WORKSPACE) or cat.get_style(style.name)
if gs_sld:
gs_styles.append((style.name, sld_title))
else:
style.delete()
except BaseException:
pass
gs_styles.append((style.name, sld_title))
tb = traceback.format_exc()
logger.debug(tb)

current_layer_styles = layer.styles.all()
layer_styles = []
Expand All @@ -257,7 +258,8 @@ def layer_style_manage(request, layername):
if style.sld_title:
sld_title = style.sld_title
except BaseException:
pass
tb = traceback.format_exc()
logger.debug(tb)
layer_styles.append((style.name, sld_title))

# Render the form
Expand All @@ -266,7 +268,8 @@ def layer_style_manage(request, layername):
if layer.default_style.sld_title:
sld_title = layer.default_style.sld_title
except BaseException:
pass
tb = traceback.format_exc()
logger.debug(tb)

default_style = (layer.default_style.name, sld_title)
return render(
Expand Down Expand Up @@ -314,10 +317,9 @@ def layer_style_manage(request, layername):
cat.get_style(default_style)
styles = []
for style in selected_styles:
styles.append(
cat.get_style(
style,
workspace=settings.DEFAULT_WORKSPACE) or cat.get_style(style))
gs_sld = cat.get_style(style, workspace=settings.DEFAULT_WORKSPACE) or cat.get_style(style)
if gs_sld:
styles.append(gs_sld)
gs_layer.styles = styles
cat.save(gs_layer)

Expand Down

0 comments on commit ea3ed73

Please sign in to comment.