requestcontext by error-pages

This commit is contained in:
Oskar Hahn 2011-09-03 19:16:43 +02:00
parent a7fc2c2b88
commit 3c38a02896
5 changed files with 25 additions and 75 deletions

View File

@ -1,31 +1,6 @@
{% extends "base.html" %}
{% load tags %}
{% block mainmenu %}
<ul>
{% if perms.agenda.can_view_agenda or perms.agenda.can_manage_agenda %}
<li>
<a href="{% url item_overview %}" title="">{%trans "Agenda" %}</a></li>
{% endif %}
{% if perms.application.can_view_application or perms.application.can_insert_application or perms.application.can_support_application or perms.application.can_manage_application %}
<li>
<a href="{% url application_overview %}" title="">{%trans "Applications" %}</a></li>
{% endif %}
{% if perms.assignment.can_view_assignment or perms.assignment.can_nominate_other or perms.assignment.can_nominate_self or perms.assignment.can_manage_assignment %}
<li>
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
{% endif %}
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
<li>
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
{% endif %}
{% if perms.system.can_manage_system %}
<li>
<a href="{% url config_general %}" title="">{%trans "Configuration" %}</a></li>
{% endif %}
</ul>
{% endblock %}
{% block submenu %}
{% endblock %}

View File

@ -1,31 +1,8 @@
{% extends "base.html" %}
{% load tags %}
{% block mainmenu %}
<ul>
{% if perms.agenda.can_view_agenda or perms.agenda.can_manage_agenda %}
<li>
<a href="{% url item_overview %}" title="">{%trans "Agenda" %}</a></li>
{% endif %}
{% if perms.application.can_view_application or perms.application.can_insert_application or perms.application.can_support_application or perms.application.can_manage_application %}
<li>
<a href="{% url application_overview %}" title="">{%trans "Applications" %}</a></li>
{% endif %}
{% if perms.assignment.can_view_assignment or perms.assignment.can_nominate_other or perms.assignment.can_nominate_self or perms.assignment.can_manage_assignment %}
<li>
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
{% endif %}
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
<li>
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
{% endif %}
{% if perms.system.can_manage_system %}
<li>
<a href="{% url config_general %}" title="">{%trans "Configuration" %}</a></li>
{% endif %}
</ul>
{% endblock %}
{% block submenu %}
{% endblock %}

View File

@ -1,31 +1,7 @@
{% extends "base.html" %}
{% load tags %}
{% block mainmenu %}
<ul>
{% if perms.agenda.can_view_agenda or perms.agenda.can_manage_agenda %}
<li>
<a href="{% url item_overview %}" title="">{%trans "Agenda" %}</a></li>
{% endif %}
{% if perms.application.can_view_application or perms.application.can_insert_application or perms.application.can_support_application or perms.application.can_manage_application %}
<li>
<a href="{% url application_overview %}" title="">{%trans "Applications" %}</a></li>
{% endif %}
{% if perms.assignment.can_view_assignment or perms.assignment.can_nominate_other or perms.assignment.can_nominate_self or perms.assignment.can_manage_assignment %}
<li>
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
{% endif %}
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
<li>
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
{% endif %}
{% if perms.system.can_manage_system %}
<li>
<a href="{% url config_general %}" title="">{%trans "Configuration" %}</a></li>
{% endif %}
</ul>
{% endblock %}
{% block submenu %}
{% endblock %}

View File

@ -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<path>.*)$', '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'),
)

16
openslides/utils/views.py Normal file
View File

@ -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)))