=== modified file 'lava_server/settings/debian.py'
@@ -1,5 +1,7 @@
# Django settings for django_hello project used on Debian systems.
+import os
+
from django_debian.settings import Settings
from lava_server.extension import loader
@@ -43,7 +45,8 @@
ADMIN_MEDIA_PREFIX = debian_settings.ADMIN_MEDIA_PREFIX
# List of absolute pathnames used to resolve templates.
-TEMPLATE_DIRS = debian_settings.TEMPLATE_DIRS
+TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), '..', 'templates')]
+TEMPLATE_DIRS.extend(debian_settings.TEMPLATE_DIRS)
# Like TEMPLATE_DIRS but for static files
STATICFILES_DIRS = debian_settings.STATICFILES_DIRS
=== modified file 'lava_server/templates/500.html'
@@ -1,9 +1,17 @@
{% extends "layouts/content.html" %}
+{% block breadcrumb_container %}{% endblock %}
+
{% block title %} | HTTP 500 {% endblock %}
{% block content %}
<h1>500 Internal Server Error</h1>
+<p>
+ Oops, something has gone wrong!
+</p>
+{% if request.sentry.id %}
+ <p>If you need assistance, you may reference this error as <strong>{{ request.sentry.id }}</strong>.</p>
+{% endif %}
{% endblock %}
=== modified file 'lava_server/urls.py'
@@ -18,7 +18,7 @@
from django.conf import settings
from django.conf.urls.defaults import (
- handler404, handler500, include, patterns, url)
+ handler404, include, patterns, url)
from django.contrib import admin
from staticfiles.urls import staticfiles_urlpatterns
from linaro_django_xmlrpc import urls as api_urls
@@ -27,6 +27,8 @@
from lava_server.views import index, me, version
+handler500 = 'lava_server.views.server_error'
+
# Enable admin stuff
admin.autodiscover()
=== modified file 'lava_server/views.py'
@@ -16,11 +16,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA Server. If not, see <http://www.gnu.org/licenses/>.
+from django.conf import settings
from django.contrib.auth.decorators import login_required
-from django.http import HttpResponse
-from django.template import loader, RequestContext
+from django.http import HttpResponse, HttpResponseServerError
+from django.template import Context, loader, RequestContext
from django.utils.translation import ugettext as _
-from django.views.generic.simple import direct_to_template
+from django.views.decorators.csrf import requires_csrf_token
from lava_server.bread_crumbs import (
BreadCrumb,
@@ -67,3 +68,16 @@
context = RequestContext(request, data)
template = loader.get_template('version_details.html')
return HttpResponse(template.render(context))
+
+
+@requires_csrf_token
+def server_error(request, template_name='500.html'):
+ t = loader.get_template(template_name)
+ return HttpResponseServerError(
+ t.render(
+ Context(
+ {
+ 'STATIC_URL':settings.STATIC_URL,
+ 'user':request.user,
+ 'request':request,
+ })))