Don't inherit from base.html in 500 error page
For server errors, the context passed to the template is empty, so things like STATIC_URL and context processors don't work. Fixes bug 1067206. Change-Id: Ia1801afaecd6a23fbcc6054552d0fd313597d1c1
This commit is contained in:
parent
699469827b
commit
76ef256dc4
@ -21,6 +21,7 @@ from django.utils.datastructures import SortedDict
|
|||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from horizon.base import Horizon
|
from horizon.base import Horizon
|
||||||
|
from horizon import conf
|
||||||
|
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@ -135,3 +136,8 @@ def jstemplate(parser, token):
|
|||||||
nodelist = parser.parse(('endjstemplate',))
|
nodelist = parser.parse(('endjstemplate',))
|
||||||
parser.delete_first_token()
|
parser.delete_first_token()
|
||||||
return JSTemplateNode(nodelist)
|
return JSTemplateNode(nodelist)
|
||||||
|
|
||||||
|
|
||||||
|
@register.assignment_tag
|
||||||
|
def load_config():
|
||||||
|
return conf.HORIZON_CONFIG
|
||||||
|
@ -1,27 +1,82 @@
|
|||||||
{% extends "base.html" %}
|
{% load branding i18n staticfiles %}
|
||||||
{% load i18n %}
|
{% load load_config from horizon %}
|
||||||
|
|
||||||
{% block title %} - {% trans "Internal Server Error" %}{% endblock %}
|
{% load_config as HORIZON_CONFIG %}
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div id="right_content">
|
{% comment %}
|
||||||
<div id="page_head">
|
|
||||||
<h2 id="page_heading">{% trans "Internal Server Error" %}</h2>
|
NB: The context for 500 pages is an empty dict.
|
||||||
<p id="page_description">{% trans "An unexpected error occurred while processing your request. Please try your request again." %}</p>
|
Don't add any content here that depends on things from
|
||||||
|
the context.
|
||||||
|
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
|
||||||
|
<link rel="shortcut icon" href="{% static "dashboard/img/favicon.ico" %}"/>
|
||||||
|
<title>{% trans "Server error" %} - {% site_branding %}</title>
|
||||||
|
{% block css %}
|
||||||
|
<style>
|
||||||
|
a {
|
||||||
|
color: #43a1d6;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
color: rgb(106, 106, 106);
|
||||||
|
text-align: center;
|
||||||
|
font-weight: normal;
|
||||||
|
background: none repeat scroll 0% 0% rgb(250, 250, 250);
|
||||||
|
}
|
||||||
|
div#container {
|
||||||
|
position: absolute;
|
||||||
|
top: 80px;
|
||||||
|
padding-top: 170px;
|
||||||
|
margin: 0px 0px 0px -196px;
|
||||||
|
left: 50%;
|
||||||
|
width: 390px;
|
||||||
|
|
||||||
|
background: url("{% static "dashboard/img/logo.png" %}") no-repeat scroll center 35px padding-box rgb(255, 255, 255);
|
||||||
|
border: 1px solid rgb(225, 225, 225);
|
||||||
|
|
||||||
|
-webkit-border-radius: 6px;
|
||||||
|
-moz-border-radius: 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
box-shadow: 0px 3px 7px rgba(0, 0, 0, 0.3);
|
||||||
|
-webkit-box-shadow: 0px 3px 7px rgba(0, 0, 0, 0.3);
|
||||||
|
-moz-box-shadow: 0px 3px 7px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
div#container > div {
|
||||||
|
padding: 25px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body id="{% block body_id %}{% endblock %}">
|
||||||
|
{% block page_header %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div id="container">
|
||||||
|
<div id="text">
|
||||||
|
{% block text %}
|
||||||
|
<h2>{% trans "Something went wrong!" %}</h2>
|
||||||
|
<p>{% trans "An unexpected error has occurred. Try refreshing the page. If that doesn't help, contact your local administrator." %}</p>
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
<div id="links">
|
||||||
|
{% block links %}
|
||||||
|
<p><a href="/">{% trans "Home" %}</a></p>
|
||||||
|
<p><a href="{{ HORIZON_CONFIG.help_url }}">{% trans "Help" %}</a></p>
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endblock %}
|
||||||
{% endblock %}
|
{% block footer %}{% endblock %}
|
||||||
|
{% block js %}{% endblock %}
|
||||||
{% block sidebar %}
|
</body>
|
||||||
<div id="sidebar">
|
</html>
|
||||||
<ul id="navigation">
|
|
||||||
{% block nav_home %}
|
|
||||||
<li><h3><a href="{% url index %}">{% trans "Home" %}</a></h3></li>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block nav_projects %}
|
|
||||||
<li><h3><a href="{% url index %}">{% trans "Projects" %}</a></h3></li>
|
|
||||||
{% endblock %}
|
|
||||||
</ul>
|
|
||||||
</div> <!-- end sidebar -->
|
|
||||||
{% endblock %}
|
|
||||||
|
7
openstack_dashboard/test/error_pages_urls.py
Normal file
7
openstack_dashboard/test/error_pages_urls.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from django.conf.urls import patterns, url, include
|
||||||
|
|
||||||
|
from openstack_dashboard.urls import urlpatterns
|
||||||
|
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
(r'^500/$', 'django.views.defaults.server_error')
|
||||||
|
)
|
34
openstack_dashboard/test/tests/error_pages.py
Normal file
34
openstack_dashboard/test/tests/error_pages.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright (c) 2012 OpenStack, LLC.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from horizon import exceptions
|
||||||
|
from openstack_dashboard.test import helpers as test
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorPageTests(test.TestCase):
|
||||||
|
""" Tests for error pages """
|
||||||
|
urls = 'openstack_dashboard.test.error_pages_urls'
|
||||||
|
|
||||||
|
def test_500_error(self):
|
||||||
|
TEMPLATE_DIRS = (path.join(settings.ROOT_PATH, 'templates'),)
|
||||||
|
with self.settings(TEMPLATE_DIRS=TEMPLATE_DIRS):
|
||||||
|
response = self.client.get('/500/')
|
||||||
|
self.assertTrue('Server error' in response.content)
|
@ -43,3 +43,8 @@ urlpatterns += staticfiles_urlpatterns()
|
|||||||
# development. Only active if DEBUG==True and the URL prefix is a local
|
# development. Only active if DEBUG==True and the URL prefix is a local
|
||||||
# path. Production media should NOT be served by Django.
|
# path. Production media should NOT be served by Django.
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
urlpatterns += patterns('',
|
||||||
|
url(r'^500/$', 'django.views.defaults.server_error')
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user