forked from CGM_Public/pretix_original
Correctly pass query string when redirecting to sudo page
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
· <a id='reload' href='#'>{% trans "Try again" %}</a>
|
· <a id='reload' href='#'>{% trans "Try again" %}</a>
|
||||||
</p>
|
</p>
|
||||||
{% if request.user.is_staff and not staff_session %}
|
{% if request.user.is_staff and not staff_session %}
|
||||||
<form action="{% url 'control:user.sudo' %}?next={{ request.path|urlencode }}" method="post">
|
<form action="{% url 'control:user.sudo' %}?next={{ request.path|add:"?"|add:request.GET.urlencode|urlencode }}" method="post">
|
||||||
<p>
|
<p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button type="submit" class="btn btn-default" id="button-sudo">
|
<button type="submit" class="btn btn-default" id="button-sudo">
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<a id='goback' href='#'>{% trans "Take a step back" %}</a>
|
<a id='goback' href='#'>{% trans "Take a step back" %}</a>
|
||||||
</p>
|
</p>
|
||||||
{% if request.user.is_staff and not staff_session %}
|
{% if request.user.is_staff and not staff_session %}
|
||||||
<form action="{% url 'control:user.sudo' %}?next={{ request.path|urlencode }}" method="post">
|
<form action="{% url 'control:user.sudo' %}?next={{ request.path|add:"?"|add:request.GET.urlencode|urlencode }}" method="post">
|
||||||
<p>
|
<p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button type="submit" class="btn btn-default" id="button-sudo">
|
<button type="submit" class="btn btn-default" id="button-sudo">
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ from django.urls import reverse
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
|
||||||
|
def current_url(request):
|
||||||
|
if len(request.GET):
|
||||||
|
return request.path + '?' + request.GET.urlencode()
|
||||||
|
else:
|
||||||
|
return request.path
|
||||||
|
|
||||||
|
|
||||||
def event_permission_required(permission):
|
def event_permission_required(permission):
|
||||||
"""
|
"""
|
||||||
This view decorator rejects all requests with a 403 response which are not from
|
This view decorator rejects all requests with a 403 response which are not from
|
||||||
@@ -94,7 +101,7 @@ def administrator_permission_required():
|
|||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
if not request.user.has_active_staff_session(request.session.session_key):
|
if not request.user.has_active_staff_session(request.session.session_key):
|
||||||
if request.user.is_staff:
|
if request.user.is_staff:
|
||||||
return redirect(reverse('control:user.sudo') + '?next=' + quote(request.path))
|
return redirect(reverse('control:user.sudo') + '?next=' + quote(current_url(request)))
|
||||||
raise PermissionDenied(_('You do not have permission to view this content.'))
|
raise PermissionDenied(_('You do not have permission to view this content.'))
|
||||||
return function(request, *args, **kw)
|
return function(request, *args, **kw)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
@@ -186,7 +186,7 @@
|
|||||||
|
|
||||||
{% if request.user.is_staff and not staff_session %}
|
{% if request.user.is_staff and not staff_session %}
|
||||||
<li>
|
<li>
|
||||||
<form action="{% url 'control:user.sudo' %}?next={{ request.path|urlencode }}" method="post">
|
<form action="{% url 'control:user.sudo' %}?next={{ request.path|add:"?"|add:request.GET.urlencode|urlencode }}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button type="submit" class="btn btn-link" id="button-sudo">
|
<button type="submit" class="btn btn-link" id="button-sudo">
|
||||||
<i class="fa fa-id-card"></i> {% trans "Admin mode" %}
|
<i class="fa fa-id-card"></i> {% trans "Admin mode" %}
|
||||||
|
|||||||
Reference in New Issue
Block a user