Skip to content

Commit

Permalink
[Regression] "style_change_check" always fails in the case the style …
Browse files Browse the repository at this point in the history
…does not exist on GeoNode too, preventing a user editing temporary generated styles
  • Loading branch information
afabiani committed Feb 23, 2022
1 parent 1c80ef9 commit 8396170
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions geonode/geoserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,22 @@ def style_change_check(request, path, access_token=None):
user = request.user
if user.is_anonymous and access_token:
user = get_auth_user(access_token)
style = Style.objects.get(name=style_name)
for layer in style.layer_styles.all():
if not user.has_perm('change_layer_style', obj=layer):
authorized = False
break
else:
authorized = True
break
except Exception:
authorized = (request.method == 'POST') # The user is probably trying to create a new style
if not user or user.is_anonymous:
authorized = False
else:
style = Style.objects.get(name=style_name)
for layer in style.layer_styles.all():
if not user.has_perm('change_layer_style', obj=layer):
authorized = False
break
else:
authorized = True
break
except Style.DoesNotExist:
logger.warn(f'There is not a style with such a name: {style_name}.')
except Exception as e:
logger.exception(e)
authorized = (request.method == 'POST') # The user is probably trying to create a new style
return authorized


Expand Down

0 comments on commit 8396170

Please sign in to comment.