=== modified file 'doc/changes.rst'
@@ -6,6 +6,7 @@
Version 0.19
============
* Unreleased.
+* Improve user experience for 403 errors
.. _version_0_18_1:
@@ -21,7 +22,7 @@
* Make token page clearer about what the token actually is.
* Enable devserver if it is available (i.e. if an instance is using
buildout-development.cfg)
-* If a table is queryset backed but not ajax enabled, render all the
+* If a table is queryset backed but not ajax enabled, render all the
data.
* Load font css over https.
=== modified file 'lava_server/templates/403.html'
@@ -3,7 +3,15 @@
{% block title %} | HTTP 403 {% endblock %}
-
{% block content %}
<h1>403 Forbidden</h1>
+
+{% if user.is_authenticated %}
+You do not have permission to view this resource.
+{% else %}
+<p>The requested resource is only for authorized users. You don't appear to be
+logged into the system. Please log in to view this.
+</p>
+{% endif %}
+
{% endblock %}
=== modified file 'lava_server/templates/layouts/content.html'
@@ -70,8 +70,13 @@
{% if user.is_authenticated %}
<a href="{% url lava.me %}" class="username">{{user.get_full_name|default:user.username}} ▾</a>
{% else %}
- <a href="{% url django.contrib.auth.views.login %}" class="username"
- >{% trans "Guest" %}</a>
+ {% if request.get_full_path == "/accounts/logout/" %}
+ <a href="{% url django.contrib.auth.views.login %}"
+ class="username">{% trans "Guest" %}</a>
+ {% else %}
+ <a href="{% url django.contrib.auth.views.login %}?next={{request.get_full_path}}"
+ class="username">{% trans "Guest" %}</a>
+ {% endif %}
{% endif %}
</div>
{% if user.is_authenticated %}
=== modified file 'lava_server/urls.py'
@@ -27,6 +27,7 @@
from lava_server.views import index, me, version
+handler403 = 'lava_server.views.permission_error'
handler500 = 'lava_server.views.server_error'
# Enable admin stuff
=== modified file 'lava_server/views.py'
@@ -86,3 +86,9 @@
'user':request.user,
'request':request,
})))
+
+@requires_csrf_token
+def permission_error(request, template_name='403.html'):
+ t = loader.get_template(template_name)
+ context = RequestContext(request)
+ return HttpResponse(t.render(context))