# 382 - Redirect as 404
* extends 404 template (user should check the URL) * introduces new decorator "uuid_required" which performs a check on a given 'uuid' or 'id' parameter * throws a Http404 exception --> redirect to 404 template instead of 500 error template
This commit is contained in:
parent
0b5691f501
commit
11cc8b6766
@ -19,7 +19,8 @@ from compensation.models import Compensation
|
||||
from compensation.tables.compensation import CompensationTable
|
||||
from intervention.models import Intervention
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import shared_access_required, default_group_required, any_group_check, login_required_modal
|
||||
from konova.decorators import shared_access_required, default_group_required, any_group_check, login_required_modal, \
|
||||
uuid_required
|
||||
from konova.forms import SimpleGeomForm
|
||||
from konova.forms.modals import RemoveModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
@ -200,6 +201,7 @@ def edit_view(request: HttpRequest, id: str):
|
||||
|
||||
@login_required
|
||||
@any_group_check
|
||||
@uuid_required
|
||||
def detail_view(request: HttpRequest, id: str):
|
||||
""" Renders a detail view for a compensation
|
||||
|
||||
|
@ -17,7 +17,8 @@ from compensation.forms.eco_account import EditEcoAccountForm, NewEcoAccountForm
|
||||
from compensation.models import EcoAccount
|
||||
from compensation.tables.eco_account import EcoAccountTable
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import shared_access_required, default_group_required, any_group_check, login_required_modal
|
||||
from konova.decorators import shared_access_required, default_group_required, any_group_check, login_required_modal, \
|
||||
uuid_required
|
||||
from konova.forms import SimpleGeomForm
|
||||
from konova.settings import ETS_GROUP, DEFAULT_GROUP, ZB_GROUP
|
||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||
@ -177,6 +178,7 @@ def edit_view(request: HttpRequest, id: str):
|
||||
|
||||
@login_required
|
||||
@any_group_check
|
||||
@uuid_required
|
||||
def detail_view(request: HttpRequest, id: str):
|
||||
""" Renders a detail view for a compensation
|
||||
|
||||
|
@ -17,7 +17,8 @@ from ema.forms import NewEmaForm, EditEmaForm
|
||||
from ema.models import Ema
|
||||
from ema.tables import EmaTable
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import shared_access_required, conservation_office_group_required, login_required_modal
|
||||
from konova.decorators import shared_access_required, conservation_office_group_required, login_required_modal, \
|
||||
uuid_required
|
||||
from konova.forms import SimpleGeomForm
|
||||
from konova.forms.modals import RemoveModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
@ -124,6 +125,7 @@ def new_id_view(request: HttpRequest):
|
||||
|
||||
|
||||
@login_required
|
||||
@uuid_required
|
||||
def detail_view(request: HttpRequest, id: str):
|
||||
""" Renders the detail view of an EMA
|
||||
|
||||
|
@ -16,7 +16,8 @@ from intervention.forms.intervention import EditInterventionForm, NewInterventio
|
||||
from intervention.models import Intervention
|
||||
from intervention.tables import InterventionTable
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import default_group_required, shared_access_required, any_group_check, login_required_modal
|
||||
from konova.decorators import default_group_required, shared_access_required, any_group_check, login_required_modal, \
|
||||
uuid_required
|
||||
from konova.forms import SimpleGeomForm
|
||||
from konova.forms.modals import RemoveModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
@ -128,6 +129,7 @@ def new_id_view(request: HttpRequest):
|
||||
|
||||
@login_required
|
||||
@any_group_check
|
||||
@uuid_required
|
||||
def detail_view(request: HttpRequest, id: str):
|
||||
""" Renders a detail view for viewing an intervention's data
|
||||
|
||||
|
@ -12,11 +12,13 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.models import Intervention
|
||||
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
|
||||
|
||||
|
@ -7,9 +7,11 @@ Created on: 16.11.20
|
||||
"""
|
||||
|
||||
from functools import wraps
|
||||
from uuid import UUID
|
||||
|
||||
from bootstrap_modal_forms.mixins import is_ajax
|
||||
from django.contrib import messages
|
||||
from django.http import Http404
|
||||
from django.shortcuts import redirect, get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -171,3 +173,20 @@ def login_required_modal(function):
|
||||
return render(request, template, context)
|
||||
return function(request, *args, **kwargs)
|
||||
return wrap
|
||||
|
||||
|
||||
def uuid_required(function):
|
||||
"""
|
||||
Checks whether the given input is a valid UUID
|
||||
"""
|
||||
@wraps(function)
|
||||
def wrap(request, *args, **kwargs):
|
||||
uuid = kwargs.get("uuid", None) or kwargs.get("id", None)
|
||||
try:
|
||||
uuid = UUID(uuid)
|
||||
except ValueError:
|
||||
raise Http404(
|
||||
"Invalid UUID"
|
||||
)
|
||||
return function(request, *args, **kwargs)
|
||||
return wrap
|
||||
|
Binary file not shown.
@ -29,7 +29,7 @@
|
||||
#: konova/filters/mixins/office.py:25 konova/filters/mixins/office.py:56
|
||||
#: konova/filters/mixins/office.py:57 konova/filters/mixins/record.py:23
|
||||
#: konova/filters/mixins/self_created.py:24 konova/filters/mixins/share.py:23
|
||||
#: konova/forms/geometry_form.py:33 konova/forms/modals/document_form.py:26
|
||||
#: konova/forms/geometry_form.py:32 konova/forms/modals/document_form.py:26
|
||||
#: konova/forms/modals/document_form.py:36
|
||||
#: konova/forms/modals/document_form.py:50
|
||||
#: konova/forms/modals/document_form.py:62
|
||||
@ -43,7 +43,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-01-09 09:46+0100\n"
|
||||
"POT-Creation-Date: 2024-02-16 09:49+0100\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"
|
||||
@ -188,7 +188,7 @@ msgstr "Einzelflächen"
|
||||
#: analysis/templates/analysis/reports/includes/intervention/laws.html:20
|
||||
#: compensation/tables/compensation.py:38
|
||||
#: compensation/templates/compensation/detail/compensation/view.html:74
|
||||
#: intervention/tables.py:38
|
||||
#: intervention/tables.py:43
|
||||
#: intervention/templates/intervention/detail/view.html:68
|
||||
#: user/models/user_action.py:21
|
||||
msgid "Checked"
|
||||
@ -207,7 +207,7 @@ msgstr "Geprüft"
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:31
|
||||
#: compensation/templates/compensation/detail/eco_account/view.html:45
|
||||
#: ema/tables.py:41 ema/templates/ema/detail/view.html:35
|
||||
#: intervention/tables.py:44
|
||||
#: intervention/tables.py:49
|
||||
#: intervention/templates/intervention/detail/view.html:87
|
||||
#: user/models/user_action.py:22
|
||||
msgid "Recorded"
|
||||
@ -273,7 +273,7 @@ msgid "Surface"
|
||||
msgstr "Fläche"
|
||||
|
||||
#: analysis/templates/analysis/reports/includes/intervention/card_intervention.html:10
|
||||
#: intervention/tables.py:65
|
||||
#: intervention/tables.py:70
|
||||
msgid "Interventions"
|
||||
msgstr "Eingriffe"
|
||||
|
||||
@ -333,7 +333,7 @@ msgstr "Typ"
|
||||
#: analysis/templates/analysis/reports/includes/old_data/amount.html:24
|
||||
#: compensation/tables/compensation.py:87
|
||||
#: intervention/forms/modals/deduction.py:58
|
||||
#: intervention/forms/modals/deduction.py:65 intervention/tables.py:87
|
||||
#: intervention/forms/modals/deduction.py:65 intervention/tables.py:92
|
||||
#: intervention/templates/intervention/detail/view.html:19
|
||||
#: konova/templates/konova/includes/quickstart/interventions.html:4
|
||||
#: templates/email/other/deduction_changed.html:27
|
||||
@ -494,7 +494,7 @@ msgstr ""
|
||||
"{}n² wurden bereits von diesem Ökokonto abgebucht. Der eingegebene Wert von "
|
||||
"{} wäre daher zu klein."
|
||||
|
||||
#: compensation/forms/eco_account.py:249
|
||||
#: compensation/forms/eco_account.py:247
|
||||
msgid "The account can not be removed, since there are still deductions."
|
||||
msgstr ""
|
||||
"Das Ökokonto kann nicht entfernt werden, da hierzu noch Abbuchungen "
|
||||
@ -781,17 +781,17 @@ msgid "Parcel gmrkng"
|
||||
msgstr "Gemarkung"
|
||||
|
||||
#: compensation/tables/compensation.py:50 compensation/tables/eco_account.py:55
|
||||
#: ema/tables.py:47 intervention/tables.py:50
|
||||
#: ema/tables.py:47 intervention/tables.py:55
|
||||
msgid "Editable"
|
||||
msgstr "Freigegeben"
|
||||
|
||||
#: compensation/tables/compensation.py:56 compensation/tables/eco_account.py:61
|
||||
#: ema/tables.py:53 intervention/tables.py:56
|
||||
#: ema/tables.py:53 intervention/tables.py:61
|
||||
msgid "Last edit"
|
||||
msgstr "Zuletzt bearbeitet"
|
||||
|
||||
#: compensation/tables/compensation.py:87 compensation/tables/eco_account.py:93
|
||||
#: ema/tables.py:86 intervention/tables.py:87
|
||||
#: ema/tables.py:86 intervention/tables.py:92
|
||||
msgid "Open {}"
|
||||
msgstr "Öffne {}"
|
||||
|
||||
@ -800,14 +800,14 @@ msgstr "Öffne {}"
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:58
|
||||
#: compensation/templates/compensation/detail/eco_account/view.html:48
|
||||
#: ema/tables.py:105 ema/templates/ema/detail/view.html:38
|
||||
#: intervention/tables.py:139
|
||||
#: intervention/tables.py:144
|
||||
#: intervention/templates/intervention/detail/view.html:90
|
||||
msgid "Not recorded yet"
|
||||
msgstr "Noch nicht verzeichnet"
|
||||
|
||||
#: compensation/tables/compensation.py:144
|
||||
#: compensation/tables/eco_account.py:133 ema/tables.py:108
|
||||
#: intervention/tables.py:142
|
||||
#: intervention/tables.py:147
|
||||
msgid "Recorded on {} by {}"
|
||||
msgstr "Am {} von {} verzeichnet worden"
|
||||
|
||||
@ -1304,7 +1304,7 @@ msgstr "Bearbeite {}"
|
||||
|
||||
#: compensation/views/compensation/report.py:34
|
||||
#: compensation/views/eco_account/report.py:34 ema/views/report.py:34
|
||||
#: intervention/views/report.py:33
|
||||
#: intervention/views/report.py:37
|
||||
msgid "Report {}"
|
||||
msgstr "Bericht {}"
|
||||
|
||||
@ -1451,10 +1451,8 @@ msgstr "Prüfung vornehmen"
|
||||
|
||||
#: intervention/forms/modals/check.py:36 konova/forms/modals/record_form.py:30
|
||||
#: konova/tests/unit/test_forms.py:155
|
||||
msgid ""
|
||||
"The necessary control steps have been performed:"
|
||||
msgstr ""
|
||||
"Die notwendigen Kontrollschritte wurden durchgeführt:"
|
||||
msgid "The necessary control steps have been performed:"
|
||||
msgstr "Die notwendigen Kontrollschritte wurden durchgeführt:"
|
||||
|
||||
#: intervention/forms/modals/deduction.py:33
|
||||
msgid "Only recorded accounts can be selected for deductions"
|
||||
@ -1677,15 +1675,15 @@ msgstr "Eingriff {} bearbeitet"
|
||||
msgid "{} removed"
|
||||
msgstr "{} entfernt"
|
||||
|
||||
#: konova/decorators.py:30
|
||||
#: konova/decorators.py:32
|
||||
msgid "You need to be staff to perform this action!"
|
||||
msgstr "Hierfür müssen Sie Mitarbeiter sein!"
|
||||
|
||||
#: konova/decorators.py:45
|
||||
#: konova/decorators.py:47
|
||||
msgid "You need to be administrator to perform this action!"
|
||||
msgstr "Hierfür müssen Sie Administrator sein!"
|
||||
|
||||
#: konova/decorators.py:63
|
||||
#: konova/decorators.py:65
|
||||
msgid ""
|
||||
"+++ Attention: You are not part of any group. You won't be able to create, "
|
||||
"edit or do anything. Please contact an administrator. +++"
|
||||
@ -1694,7 +1692,7 @@ msgstr ""
|
||||
"somit nichts eingeben, bearbeiten oder sonstige Aktionen ausführen. "
|
||||
"Kontaktieren Sie bitte einen Administrator. +++"
|
||||
|
||||
#: konova/decorators.py:169
|
||||
#: konova/decorators.py:171
|
||||
msgid "Session timed out"
|
||||
msgstr "Sitzung abgelaufen"
|
||||
|
||||
@ -1791,17 +1789,17 @@ msgstr "Speichern"
|
||||
msgid "Not editable"
|
||||
msgstr "Nicht editierbar"
|
||||
|
||||
#: konova/forms/geometry_form.py:32 konova/utils/quality.py:44
|
||||
#: konova/forms/geometry_form.py:31 konova/utils/quality.py:44
|
||||
#: konova/utils/quality.py:46 templates/form/collapsable/form.html:45
|
||||
msgid "Geometry"
|
||||
msgstr "Geometrie"
|
||||
|
||||
#: konova/forms/geometry_form.py:101
|
||||
#: konova/forms/geometry_form.py:100
|
||||
msgid "Only surfaces allowed. Points or lines must be buffered."
|
||||
msgstr ""
|
||||
"Nur Flächen erlaubt. Punkte oder Linien müssen zu Flächen gepuffert werden."
|
||||
|
||||
#: konova/forms/geometry_form.py:154
|
||||
#: konova/forms/geometry_form.py:153
|
||||
msgid "Geometry must be greater than 1m². Currently is {}m²"
|
||||
msgstr "Geometrie muss größer als 1m² sein. Aktueller Flächeninhalt: {}m²"
|
||||
|
||||
@ -2288,11 +2286,11 @@ msgstr "{} wurde erfolgreich vom Nutzer {} geprüft! {}"
|
||||
msgid "missing"
|
||||
msgstr "fehlend"
|
||||
|
||||
#: konova/utils/tables.py:218
|
||||
#: konova/utils/tables.py:222
|
||||
msgid "Full access granted"
|
||||
msgstr "Für Sie freigegeben - Datensatz kann bearbeitet werden"
|
||||
|
||||
#: konova/utils/tables.py:218
|
||||
#: konova/utils/tables.py:222
|
||||
msgid "Access not granted"
|
||||
msgstr "Nicht freigegeben - Datensatz nur lesbar"
|
||||
|
||||
@ -2382,6 +2380,10 @@ msgstr "Nicht gefunden"
|
||||
msgid "The requested data does not exist."
|
||||
msgstr "Die angeforderten Daten existieren nicht."
|
||||
|
||||
#: templates/404.html:11
|
||||
msgid "Make sure the URL is valid (no whitespaces, ...)."
|
||||
msgstr "Stellen Sie sicher, dass die URL gültig ist (keine Leerzeichen, ...)."
|
||||
|
||||
#: templates/500.html:7
|
||||
msgid "Server Error"
|
||||
msgstr ""
|
||||
|
@ -8,6 +8,7 @@
|
||||
<hr>
|
||||
<p class="lead">
|
||||
{% trans 'The requested data does not exist.' %}
|
||||
{% trans 'Make sure the URL is valid (no whitespaces, ...).' %}
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user