Skip to content

Commit

Permalink
🩹 [#990] FIX wrong user redirect on form submit or cancel.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefrado committed Nov 19, 2024
1 parent e8cb15b commit 4cbad9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/sdg/organisaties/views/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ def get_form_class(self):

raise PermissionDenied()

def get_success_url(self):
# Stay on the same page if the user is editing own settings and is not an admin.
if (
self.request.user.email == self.object.user.email
and self.object.is_beheerder is not True
):
return self.request.get_full_path()
return super().get_success_url()

def form_valid(self, form, *args, **kwargs):
response = super().form_valid(form)

Expand Down
10 changes: 5 additions & 5 deletions src/sdg/templates/organisaties/roles/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
{% endfor %}
</div>
</div>
{% if request.user.email == role.user.email and role.is_beheerder is not True %}
{% url 'organisaties:roles:update' pk=lokaleoverheid.pk role_pk=role.pk as cancel_url %}
{% else %}
{% url 'organisaties:roles:list' pk=lokaleoverheid.pk as cancel_url %}
{% endif %}
<input type="hidden" name="next" value="{{ redirect_field_value }}">
<hr class="divider">
<div class="form__buttons">
<input type="submit" class="button" value="{% trans 'Opslaan' %}">
{% if request.user.email == role.user.email and role.is_beheerder is not True %}
{% url 'organisaties:roles:update' pk=lokaleoverheid.pk role_pk=role.pk as cancel_url %}
{% else %}
{% url 'organisaties:roles:list' pk=lokaleoverheid.pk as cancel_url %}
{% endif %}
<a href="{{cancel_url}}">
<button type="button" class="button button--light">{% trans 'Annuleren' %}</button>
</a>
Expand Down

0 comments on commit 4cbad9b

Please sign in to comment.