Skip to content

Commit

Permalink
[Fixes #9987] Avoid call to delete the style if is the default one (#…
Browse files Browse the repository at this point in the history
…9988)

* [Fixes #9987] Avoid call to delete the style if is the default one

* [Fixes #9987] Avoid call to delete the style if is the default one
  • Loading branch information
mattiagiupponi authored Sep 9, 2022
1 parent e2dac05 commit 089ace0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
('text/csv', 'vector')
]

DEFAULT_STYLE_NAME = ['generic', 'line', 'point', 'polygon', 'raster']


if not hasattr(settings, 'OGC_SERVER'):
msg = (
Expand Down Expand Up @@ -1178,13 +1180,14 @@ def set_styles(layer, gs_catalog):
if default_style.name != _gs_default_style.name or default_style.workspace != _gs_default_style.workspace:
gs_dataset.default_style = _gs_default_style
gs_catalog.save(gs_dataset)
gs_catalog.delete(
gs_catalog.get_style(
name=default_style.name,
workspace=None,
recursive=True),
purge=True,
recurse=False)
if default_style.name not in DEFAULT_STYLE_NAME:
gs_catalog.delete(
gs_catalog.get_style(
name=default_style.name,
workspace=None,
recursive=True),
purge=True,
recurse=False)
except Exception as e:
logger.exception(e)
style_set.append(layer.default_style)
Expand Down

0 comments on commit 089ace0

Please sign in to comment.