From cf5b073d44b0e01267607fe8e332d77bb8e9dcd7 2016-12-06 02:43:51 From: Brett Smith Date: 2016-12-06 02:43:51 Subject: [PATCH] urls: Route /error/NNN/ to static.views.handler. Since our Apache configuration uses `ErrorDocument NNN /error/NNN/`, this is necessary to return the correct status code in those cases. --- diff --git a/www/conservancy/static/views.py b/www/conservancy/static/views.py index 36985e5309ef69f6f5ecc2db2dc5caf4e3455093..a07296ce32c39ae2105404e23decd923b3b745ea 100644 --- a/www/conservancy/static/views.py +++ b/www/conservancy/static/views.py @@ -14,7 +14,7 @@ def handler(request, errorcode): return HttpResponse("Internal error: " + path) template = loader.get_template(path) context = RequestContext(request) - return HttpResponse(template.render(context), status=errorcode) + return HttpResponse(template.render(context), status=int(errorcode)) def handler401(request): return handler(request, 401) diff --git a/www/conservancy/urls.py b/www/conservancy/urls.py index 4c19cd16c33f0f4c2d3c53ee3383db8d3de7bcc3..7a167d0d271b10e5b70a32a3642d35b0ee0d8623 100644 --- a/www/conservancy/urls.py +++ b/www/conservancy/urls.py @@ -50,6 +50,7 @@ urlpatterns = patterns('', (r'^news(/|$)', include('conservancy.apps.news.urls')), (r'^blog(/|$)', include('conservancy.apps.blog.urls')), # formerly static templated things... (dirs with templates) + (r'^error/(40[134]|500)(?:/index\.html|/|)$', 'conservancy.static.views.handler'), (r'^error', 'conservancy.static.views.index'), (r'^about', 'conservancy.static.views.index'), (r'^donate', 'conservancy.static.views.index'),