From a7fc2c2b889f03c506971c46168a48a812d53bc8 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 3 Sep 2011 18:50:47 +0200 Subject: [PATCH 1/2] show a discreet error when there is an ajax-error on the beamer --- openslides/static/javascript/beamer.js | 5 ++--- openslides/static/styles/beamer.css | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openslides/static/javascript/beamer.js b/openslides/static/javascript/beamer.js index 1d4953c25..ea84d3d3b 100644 --- a/openslides/static/javascript/beamer.js +++ b/openslides/static/javascript/beamer.js @@ -9,11 +9,10 @@ function presentation_reload() { $('#content').html(data.content); document.title = data.title; $('#currentTime').html(data.time); - setTimeout("presentation_reload()",500); - + setTimeout("presentation_reload()", 500); }, error: function () { - alert("Ajax Error"); + $('#currentTime').addClass('ajax_error'); } }); } diff --git a/openslides/static/styles/beamer.css b/openslides/static/styles/beamer.css index 7182ae341..8f4c0018b 100644 --- a/openslides/static/styles/beamer.css +++ b/openslides/static/styles/beamer.css @@ -57,6 +57,10 @@ body{ background: url(../images/icons/clock.png) no-repeat scroll 0px 4px; } +#currentTime.ajax_error { + border-bottom: 4px solid red; +} + /*** CONTENT ***/ #content { position:absolute; From 3c38a02896c36e152e9147d50dfd662f9d3e9d64 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 3 Sep 2011 19:16:43 +0200 Subject: [PATCH 2/2] requestcontext by error-pages --- openslides/templates/403.html | 25 ------------------------- openslides/templates/404.html | 27 ++------------------------- openslides/templates/500.html | 26 +------------------------- openslides/urls.py | 6 ++++++ openslides/utils/views.py | 16 ++++++++++++++++ 5 files changed, 25 insertions(+), 75 deletions(-) create mode 100644 openslides/utils/views.py diff --git a/openslides/templates/403.html b/openslides/templates/403.html index 99ea3fbdc..f7d59da78 100644 --- a/openslides/templates/403.html +++ b/openslides/templates/403.html @@ -1,31 +1,6 @@ {% extends "base.html" %} {% load tags %} -{% block mainmenu %} - - {% endblock %} - {% block submenu %} {% endblock %} diff --git a/openslides/templates/404.html b/openslides/templates/404.html index 207553df0..0f0a6d328 100644 --- a/openslides/templates/404.html +++ b/openslides/templates/404.html @@ -1,31 +1,8 @@ {% extends "base.html" %} {% load tags %} -{% block mainmenu %} - - {% endblock %} - + + {% block submenu %} {% endblock %} diff --git a/openslides/templates/500.html b/openslides/templates/500.html index fdb3fafc4..8c51a4f9f 100644 --- a/openslides/templates/500.html +++ b/openslides/templates/500.html @@ -1,31 +1,7 @@ {% extends "base.html" %} {% load tags %} -{% block mainmenu %} - - {% endblock %} - + {% block submenu %} {% endblock %} diff --git a/openslides/urls.py b/openslides/urls.py index ee6cb8130..55bb349f8 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -15,6 +15,7 @@ from django.conf import settings from django.contrib import admin admin.autodiscover() +handler500 = 'openslides.utils.views.server_error' urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), @@ -26,3 +27,8 @@ urlpatterns = patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), (r'^i18n/', include('django.conf.urls.i18n')), ) + + +urlpatterns += patterns('', + (r'^500/$', 'openslides.utils.views.server_error'), +) diff --git a/openslides/utils/views.py b/openslides/utils/views.py new file mode 100644 index 000000000..0d17cfa94 --- /dev/null +++ b/openslides/utils/views.py @@ -0,0 +1,16 @@ +from django.conf import settings +from django.http import HttpResponseServerError +from django.template import Context, loader, RequestContext +from django.template.loader import render_to_string + +def server_error(request, template_name='500.html'): + """ + 500 error handler. + + Templates: `500.html` + Context: + MEDIA_URL + Path of static media (e.g. "media.example.org") + """ + t = loader.get_template("500.html") # You need to create a 500.html template. + return HttpResponseServerError(render_to_string('500.html', context_instance=RequestContext(request)))