# Issue 475
* adds proper handling in case of BadRequest (error 400) * enhances html template for error 500 * adds new html template for error 400 * adds uuid_required decorator to missing views * updates translations
This commit is contained in:
		
							parent
							
								
									6fe67a8fbf
								
							
						
					
					
						commit
						62fc019127
					
				@ -12,11 +12,12 @@ from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from compensation.models import Compensation
 | 
			
		||||
from konova.contexts import BaseContext
 | 
			
		||||
from konova.decorators import uuid_required
 | 
			
		||||
from konova.forms import SimpleGeomForm
 | 
			
		||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
 | 
			
		||||
from konova.utils.generators import generate_qr_code
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@uuid_required
 | 
			
		||||
def report_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders the public report view
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -12,11 +12,13 @@ from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from compensation.models import EcoAccount
 | 
			
		||||
from konova.contexts import BaseContext
 | 
			
		||||
from konova.decorators import uuid_required
 | 
			
		||||
from konova.forms import SimpleGeomForm
 | 
			
		||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
 | 
			
		||||
from konova.utils.generators import generate_qr_code
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@uuid_required
 | 
			
		||||
def report_view(request: HttpRequest, id: str):
 | 
			
		||||
    """ Renders the public report view
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -12,11 +12,12 @@ from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from ema.models import Ema
 | 
			
		||||
from konova.contexts import BaseContext
 | 
			
		||||
from konova.decorators import uuid_required
 | 
			
		||||
from konova.forms import SimpleGeomForm
 | 
			
		||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
 | 
			
		||||
from konova.utils.generators import generate_qr_code
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@uuid_required
 | 
			
		||||
def report_view(request:HttpRequest, id: str):
 | 
			
		||||
    """ Renders the public report view
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,7 @@ from uuid import UUID
 | 
			
		||||
 | 
			
		||||
from bootstrap_modal_forms.mixins import is_ajax
 | 
			
		||||
from django.contrib import messages
 | 
			
		||||
from django.http import Http404
 | 
			
		||||
from django.core.exceptions import BadRequest
 | 
			
		||||
from django.shortcuts import redirect, get_object_or_404, render
 | 
			
		||||
from django.urls import reverse
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
@ -185,7 +185,7 @@ def uuid_required(function):
 | 
			
		||||
        try:
 | 
			
		||||
            uuid = UUID(uuid)
 | 
			
		||||
        except ValueError:
 | 
			
		||||
            raise Http404(
 | 
			
		||||
            raise BadRequest(
 | 
			
		||||
                "Invalid UUID"
 | 
			
		||||
            )
 | 
			
		||||
        return function(request, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								konova/static/images/error_imgs/croc_technician_400.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								konova/static/images/error_imgs/croc_technician_400.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.6 MiB  | 
							
								
								
									
										
											BIN
										
									
								
								konova/static/images/error_imgs/croc_technician_500.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								konova/static/images/error_imgs/croc_technician_500.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.7 MiB  | 
@ -42,5 +42,6 @@ urlpatterns = [
 | 
			
		||||
    path('client/proxy/wfs', ClientProxyParcelWFS.as_view(), name="client-proxy-wfs"),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
handler400 = "konova.views.error.get_400_view"
 | 
			
		||||
handler404 = "konova.views.error.get_404_view"
 | 
			
		||||
handler500 = "konova.views.error.get_500_view"
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,20 @@ def get_404_view(request: HttpRequest, exception=None):
 | 
			
		||||
    return render(request, "404.html", context, status=404)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_400_view(request: HttpRequest, exception=None):
 | 
			
		||||
    """ Returns a 400 handling view
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        request ():
 | 
			
		||||
        exception ():
 | 
			
		||||
 | 
			
		||||
    Returns:
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    context = BaseContext.context
 | 
			
		||||
    return render(request, "400.html", context, status=400)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_500_view(request: HttpRequest):
 | 
			
		||||
    """ Returns a 404 handling view
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@ -45,7 +45,7 @@ msgid ""
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Project-Id-Version: PACKAGE VERSION\n"
 | 
			
		||||
"Report-Msgid-Bugs-To: \n"
 | 
			
		||||
"POT-Creation-Date: 2025-01-08 15:26+0100\n"
 | 
			
		||||
"POT-Creation-Date: 2025-05-12 14:22+0200\n"
 | 
			
		||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 | 
			
		||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 | 
			
		||||
"Language-Team: LANGUAGE <LL@li.org>\n"
 | 
			
		||||
@ -1303,8 +1303,8 @@ msgstr "Kompensation {} bearbeitet"
 | 
			
		||||
msgid "Edit {}"
 | 
			
		||||
msgstr "Bearbeite {}"
 | 
			
		||||
 | 
			
		||||
#: compensation/views/compensation/report.py:34
 | 
			
		||||
#: compensation/views/eco_account/report.py:34 ema/views/report.py:34
 | 
			
		||||
#: compensation/views/compensation/report.py:35
 | 
			
		||||
#: compensation/views/eco_account/report.py:35 ema/views/report.py:35
 | 
			
		||||
#: intervention/views/report.py:35
 | 
			
		||||
msgid "Report {}"
 | 
			
		||||
msgstr "Bericht {}"
 | 
			
		||||
@ -1928,11 +1928,11 @@ msgstr "Kontrolle am"
 | 
			
		||||
msgid "Other"
 | 
			
		||||
msgstr "Sonstige"
 | 
			
		||||
 | 
			
		||||
#: konova/sub_settings/django_settings.py:157
 | 
			
		||||
#: konova/sub_settings/django_settings.py:156
 | 
			
		||||
msgid "German"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
#: konova/sub_settings/django_settings.py:158
 | 
			
		||||
#: konova/sub_settings/django_settings.py:157
 | 
			
		||||
msgid "English"
 | 
			
		||||
msgstr ""
 | 
			
		||||
 | 
			
		||||
@ -2287,18 +2287,6 @@ msgstr "Momentane Daten noch nicht geprüft"
 | 
			
		||||
msgid "New token generated. Administrators need to validate."
 | 
			
		||||
msgstr "Neuer Token generiert. Administratoren sind informiert."
 | 
			
		||||
 | 
			
		||||
#: konova/utils/messenger.py:70
 | 
			
		||||
msgid "{} checked"
 | 
			
		||||
msgstr "{} geprüft"
 | 
			
		||||
 | 
			
		||||
#: konova/utils/messenger.py:72
 | 
			
		||||
msgid "<a href=\"{}\">Check it out</a>"
 | 
			
		||||
msgstr "<a href=\"{}\">Schauen Sie rein</a>"
 | 
			
		||||
 | 
			
		||||
#: konova/utils/messenger.py:73
 | 
			
		||||
msgid "{} has been checked successfully by user {}! {}"
 | 
			
		||||
msgstr "{} wurde erfolgreich vom Nutzer {} geprüft! {}"
 | 
			
		||||
 | 
			
		||||
#: konova/utils/quality.py:32
 | 
			
		||||
msgid "missing"
 | 
			
		||||
msgstr "fehlend"
 | 
			
		||||
@ -2389,6 +2377,18 @@ msgstr "Alle"
 | 
			
		||||
msgid "News"
 | 
			
		||||
msgstr "Neuigkeiten"
 | 
			
		||||
 | 
			
		||||
#: templates/400.html:7
 | 
			
		||||
msgid "Request was invalid"
 | 
			
		||||
msgstr "Anfrage fehlerhaft"
 | 
			
		||||
 | 
			
		||||
#: templates/400.html:10
 | 
			
		||||
msgid "There seems to be a problem with the link you opened."
 | 
			
		||||
msgstr "Es scheint ein Problem mit dem Link zu geben, den Sie geöffnet haben."
 | 
			
		||||
 | 
			
		||||
#: templates/400.html:11
 | 
			
		||||
msgid "Make sure the URL is valid (no whitespaces, properly copied, ...)."
 | 
			
		||||
msgstr "Stellen Sie sicher, dass die URL gültig ist (keine Leerzeichen, fehlerfrei kopiert, ...)."
 | 
			
		||||
 | 
			
		||||
#: templates/404.html:7
 | 
			
		||||
msgid "Not found"
 | 
			
		||||
msgstr "Nicht gefunden"
 | 
			
		||||
@ -2884,7 +2884,8 @@ msgid ""
 | 
			
		||||
"You are about to create a new API token. The existing one will not be usable "
 | 
			
		||||
"afterwards."
 | 
			
		||||
msgstr ""
 | 
			
		||||
"Wenn Sie fortfahren, generieren Sie einen neuen API Token. Ihren existierenden werden Sie dann nicht länger nutzen können."
 | 
			
		||||
"Wenn Sie fortfahren, generieren Sie einen neuen API Token. Ihren "
 | 
			
		||||
"existierenden werden Sie dann nicht länger nutzen können."
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/api_token.py:31
 | 
			
		||||
msgid "A new token needs to be validated by an administrator!"
 | 
			
		||||
@ -2912,11 +2913,11 @@ msgstr ""
 | 
			
		||||
"Mehrfachauswahl möglich - Sie können nur Nutzer wählen, die noch nicht "
 | 
			
		||||
"Mitglieder dieses Teams sind. Geben Sie den ganzen Nutzernamen an."
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/team.py:56 user/tests/unit/test_forms.py:29
 | 
			
		||||
#: user/forms/modals/team.py:56 user/tests/unit/test_forms.py:30
 | 
			
		||||
msgid "Create new team"
 | 
			
		||||
msgstr "Neues Team anlegen"
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/team.py:57 user/tests/unit/test_forms.py:30
 | 
			
		||||
#: user/forms/modals/team.py:57 user/tests/unit/test_forms.py:31
 | 
			
		||||
msgid ""
 | 
			
		||||
"You will become the administrator for this group by default. You do not need "
 | 
			
		||||
"to add yourself to the list of members."
 | 
			
		||||
@ -2945,11 +2946,11 @@ msgid "There must be at least one admin on this team."
 | 
			
		||||
msgstr "Es muss mindestens einen Administrator für das Team geben."
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/team.py:160 user/templates/user/team/index.html:60
 | 
			
		||||
#: user/tests/unit/test_forms.py:86
 | 
			
		||||
#: user/tests/unit/test_forms.py:87
 | 
			
		||||
msgid "Edit team"
 | 
			
		||||
msgstr "Team bearbeiten"
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/team.py:187 user/tests/unit/test_forms.py:163
 | 
			
		||||
#: user/forms/modals/team.py:187 user/tests/unit/test_forms.py:164
 | 
			
		||||
msgid ""
 | 
			
		||||
"ATTENTION!\n"
 | 
			
		||||
"\n"
 | 
			
		||||
@ -2966,7 +2967,7 @@ msgstr ""
 | 
			
		||||
"Sind Sie sicher, dass Sie dieses Team löschen möchten?"
 | 
			
		||||
 | 
			
		||||
#: user/forms/modals/team.py:197 user/templates/user/team/index.html:56
 | 
			
		||||
#: user/tests/unit/test_forms.py:196
 | 
			
		||||
#: user/tests/unit/test_forms.py:197
 | 
			
		||||
msgid "Leave team"
 | 
			
		||||
msgstr "Team verlassen"
 | 
			
		||||
 | 
			
		||||
@ -2998,7 +2999,7 @@ msgstr "Benachrichtigungen"
 | 
			
		||||
msgid "Select the situations when you want to receive a notification"
 | 
			
		||||
msgstr "Wann wollen Sie per E-Mail benachrichtigt werden?"
 | 
			
		||||
 | 
			
		||||
#: user/forms/user.py:38 user/tests/unit/test_forms.py:232
 | 
			
		||||
#: user/forms/user.py:38 user/tests/unit/test_forms.py:233
 | 
			
		||||
msgid "Edit notifications"
 | 
			
		||||
msgstr "Benachrichtigungen bearbeiten"
 | 
			
		||||
 | 
			
		||||
@ -3112,7 +3113,7 @@ msgstr "Token noch nicht freigeschaltet"
 | 
			
		||||
msgid "Valid until"
 | 
			
		||||
msgstr "Läuft ab am"
 | 
			
		||||
 | 
			
		||||
#: user/views/api_token.py:33
 | 
			
		||||
#: user/views/api_token.py:34
 | 
			
		||||
msgid "User API token"
 | 
			
		||||
msgstr "API Nutzer Token"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								templates/400.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								templates/400.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
{% extends 'public_base.html' %}
 | 
			
		||||
{% load i18n fontawesome_5 static %}
 | 
			
		||||
 | 
			
		||||
{% block body %}
 | 
			
		||||
    <div class="jumbotron">
 | 
			
		||||
        <div class="row">
 | 
			
		||||
            <div class="col-auto">
 | 
			
		||||
                <img src="{% static 'images/error_imgs/croc_technician_400.png' %}" style="max-width: 150px">
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
 | 
			
		||||
                <h1 class="display-4">{% fa5_icon 'question-circle' %}400</h1>
 | 
			
		||||
                <h1 class="display-4">{% trans 'Request was invalid' %}</h1>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <hr>
 | 
			
		||||
        <p class="lead">
 | 
			
		||||
            {% trans 'There seems to be a problem with the link you opened.' %}
 | 
			
		||||
            {% trans 'Make sure the URL is valid (no whitespaces, properly copied, ...).' %}
 | 
			
		||||
        </p>
 | 
			
		||||
    </div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@ -1,10 +1,17 @@
 | 
			
		||||
{% extends 'public_base.html' %}
 | 
			
		||||
{% load i18n fontawesome_5 %}
 | 
			
		||||
{% load i18n fontawesome_5 static %}
 | 
			
		||||
 | 
			
		||||
{% block body %}
 | 
			
		||||
    <div class="jumbotron">
 | 
			
		||||
        <h1 class="display-4">{% fa5_icon 'fire-extinguisher' %} {% fa5_icon 'fire-alt' %} 500</h1>
 | 
			
		||||
        <div class="row">
 | 
			
		||||
            <div class="col-auto">
 | 
			
		||||
                <img src="{% static 'images/error_imgs/croc_technician_500.png' %}" style="max-width: 150px">
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="col-sm-12 col-md-9 col-lg-9 col-xl-10">
 | 
			
		||||
                <h1 class="display-4">{% fa5_icon 'fire-alt' %} 500</h1>
 | 
			
		||||
                <h1 class="display-4">{% trans 'Server Error' %}</h1>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <hr>
 | 
			
		||||
        <p class="lead">
 | 
			
		||||
            {% trans 'Something happened. Admins have been informed. We are working on it!' %}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user