diff --git a/gawa/gawa/urls.py b/gawa/gawa/urls.py index 4c4b561..26c88d8 100644 --- a/gawa/gawa/urls.py +++ b/gawa/gawa/urls.py @@ -29,11 +29,3 @@ urlpatterns += i18n_patterns( path("blog/", include("blog.urls")), path('admin/', admin.site.urls, name="admin"), ) - -# use my fancy error pages -# better yet, don't let it come to that -# FIXME these break the server. something is wrong with them -handler400 = 'start.views.Error400' -handler403 = 'start.views.Error403' -handler404 = 'start.views.Error404' -#handler500 = 'start.views.Error500' diff --git a/gawa/start/templates/400.html b/gawa/start/templates/400.html new file mode 100644 index 0000000..5d98112 --- /dev/null +++ b/gawa/start/templates/400.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %} +{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %} +{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %} +{% block main %} +
+

400 {% translate "Bad request" %}

+

{% translate "You sent bad data to the server." %}

+
+
+

{% translate "Looking for anything specific?" %}

+ {% include 'main_search_form.html' %} +
+{% endblock main %} diff --git a/gawa/start/templates/403.html b/gawa/start/templates/403.html new file mode 100644 index 0000000..7e8e75e --- /dev/null +++ b/gawa/start/templates/403.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %} +{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %} +{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %} +{% block main %} +
+

403 {% translate "Permission denied" %}

+

{% translate "You are not allowed to access this page." %}

+
+
+

{% translate "Looking for anything specific?" %}

+ {% include 'main_search_form.html' %} +
+{% endblock main %} diff --git a/gawa/start/templates/404.html b/gawa/start/templates/404.html new file mode 100644 index 0000000..3153bef --- /dev/null +++ b/gawa/start/templates/404.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %} +{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %} +{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %} +{% block main %} +
+

404 {% translate "Not found" %}

+

{% translate "The resource you are looking for does not exist." %}

+
+
+

{% translate "Looking for anything specific?" %}

+ {% include 'main_search_form.html' %} +
+{% endblock main %} diff --git a/gawa/start/templates/500.html b/gawa/start/templates/500.html new file mode 100644 index 0000000..cfc873d --- /dev/null +++ b/gawa/start/templates/500.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %} +{% block languagecode %}{{ LANGUAGE_CODE }}{% endblock languagecode %} +{% block title %}{% translate "cscherr.de" %} - {% translate "startpage" %}{% endblock title %} +{% block main %} +
+

500 {% translate "Internal Server Error" %}

+

{% translate "Something went wrong." %}

+
+
+

{% translate "Looking for anything specific?" %}

+ {% include 'main_search_form.html' %} +
+{% endblock main %} diff --git a/gawa/start/views.py b/gawa/start/views.py index dc1d222..d0cb392 100644 --- a/gawa/start/views.py +++ b/gawa/start/views.py @@ -15,6 +15,9 @@ from .models import Link, Searchable from abc import ABC +import logging +logger = logging.getLogger(__name__) + class SearchableView(View, ABC): """ This abstract view implements some traits of views that should show up @@ -105,48 +108,3 @@ class Links(ListView): ) object_list = object_list.filter(public=True) return object_list - -def Error400(request, exception): - """ - 400 View, the user did some bad request. - """ - - template_name = "errors/400.html" - t = loader.get_template(template_name) - data = {'exception': exception} - return HttpResponseBadRequest(t.render(data, request), content_type='application/xhtml+xml') - -def Error403(request, exception): - """ - 403 View, the user has been denied permission - """ - - template_name = "errors/403.html" - t = loader.get_template(template_name) - data = {'exception': exception} - return HttpResponseForbidden(t.render(data, request), content_type='application/xhtml+xml') - -def Error404(request, exception): - """ - 404 View, whatever you are looking for does not exist. - - Officially at least, might also mean that it does not exist for you - """ - - template_name = "errors/404.html" - t = loader.get_template(template_name) - data = {'exception': exception} - return HttpResponseNotFound(t.render(data, request), content_type='application/xhtml+xml') - -def Error500(request): - """ - 500 View, internal server error - - That probably means I programmed something badly - """ - - template_name = "errors/500.html" - t = loader.get_template(template_name) - data = {} - return HttpResponseServerError(t.render(data, request), content_type='application/xhtml+xml') -