From fb6e703b6742d3c41319fdd277d878960cdb9ef6 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Thu, 18 May 2023 12:30:55 +0200 Subject: [PATCH] Add error pages --- pflaenzli/pflaenzli/templates/error/404.html | 21 ++++++++++++++++++ pflaenzli/pflaenzli/templates/error/500.html | 23 ++++++++++++++++++++ pflaenzli/pflaenzli/views.py | 9 +++++++- pflaenzli/pflaenzli_django/urls.py | 3 +++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 pflaenzli/pflaenzli/templates/error/404.html create mode 100644 pflaenzli/pflaenzli/templates/error/500.html diff --git a/pflaenzli/pflaenzli/templates/error/404.html b/pflaenzli/pflaenzli/templates/error/404.html new file mode 100644 index 0000000..2bb9327 --- /dev/null +++ b/pflaenzli/pflaenzli/templates/error/404.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %} + {% trans "Not found" %} +{% endblock title %} +{% block content %} +
+

+ Error 404 {% trans "Page not found" %} +

+

+ {% blocktrans %} + Alas! Your path has led you astray in the depths of the enchanted forest. The elusive plant you seek has hidden + itself amidst the mystical foliage. If you have a map, please share it with us! + {% endblocktrans %} +

+

{% trans "What now?" %}

+ {% trans "Go home" %} + {% trans "Report error" %} +
+{% endblock content %} diff --git a/pflaenzli/pflaenzli/templates/error/500.html b/pflaenzli/pflaenzli/templates/error/500.html new file mode 100644 index 0000000..45cda34 --- /dev/null +++ b/pflaenzli/pflaenzli/templates/error/500.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %} + {% trans "Not found" %} +{% endblock title %} +{% block content %} +
+

+ Error 500 {% trans "Page not found" %} +

+

+ {% blocktrans %} + Uh-oh! The delicate balance of the botanical realms has been disrupted. The forces of nature are in disarray, + and our plant guardians are diligently working to restore harmony. We apologize for any inconvenience caused + during this mystical turbulence. Please bear with us as we channel our magic to mend the rupture. Please + contact us, if you have any information that could help to disspell the dark magic! + {% endblocktrans %} +

+

{% trans "What now?" %}

+ {% trans "Go home" %} + {% trans "Report error" %} +
+{% endblock content %} diff --git a/pflaenzli/pflaenzli/views.py b/pflaenzli/pflaenzli/views.py index f5dec0d..291c7f3 100644 --- a/pflaenzli/pflaenzli/views.py +++ b/pflaenzli/pflaenzli/views.py @@ -182,7 +182,14 @@ def register_user(request): else: form = RegistrationForm() - return render(request, "basic_form.html", {"form": form, "button_label": _("Register"), "title": _("Registeration")}) + + +def error_404(request, exception): + return render(request, 'error/404.html') + + +def error_500(request): + return render(request, 'error/500.html') def filter_offers(offers, form): diff --git a/pflaenzli/pflaenzli_django/urls.py b/pflaenzli/pflaenzli_django/urls.py index fdfc4dc..8c81db0 100644 --- a/pflaenzli/pflaenzli_django/urls.py +++ b/pflaenzli/pflaenzli_django/urls.py @@ -26,3 +26,6 @@ urlpatterns = [ ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +handler404 = 'pflaenzli.views.error_404' +handler500 = 'pflaenzli.views.error_500'