Merge pull request '# Improves form date checking' (#335) from 334_nrealistic_dates into master
Reviewed-on: SGD-Nord/konova#335
This commit is contained in:
commit
dd9d10f6fc
@ -13,6 +13,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from codelist.models import KonovaCode
|
||||
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID
|
||||
from konova.forms import BaseForm
|
||||
from konova.utils import validators
|
||||
|
||||
|
||||
class TimespanReportForm(BaseForm):
|
||||
@ -22,6 +23,7 @@ class TimespanReportForm(BaseForm):
|
||||
date_from = forms.DateField(
|
||||
label_suffix="",
|
||||
label=_("From"),
|
||||
validators=[validators.reasonable_date],
|
||||
help_text=_("Entries created from..."),
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
@ -35,6 +37,7 @@ class TimespanReportForm(BaseForm):
|
||||
date_to = forms.DateField(
|
||||
label_suffix="",
|
||||
label=_("To"),
|
||||
validators=[validators.reasonable_date],
|
||||
help_text=_("Entries created until..."),
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
|
@ -15,6 +15,7 @@ from compensation.models import EcoAccount
|
||||
from intervention.models import Handler, Responsibility, Legal
|
||||
from konova.forms import SimpleGeomForm
|
||||
from konova.forms.modals import RemoveModalForm
|
||||
from konova.utils import validators
|
||||
from user.models import User, UserActionLogEntry
|
||||
|
||||
|
||||
@ -43,6 +44,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
label_suffix="",
|
||||
help_text=_("When did the parties agree on this?"),
|
||||
required=False,
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
@ -10,6 +10,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.forms.modals import BaseModalForm
|
||||
from konova.models import DeadlineType
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import DEADLINE_EDITED
|
||||
|
||||
|
||||
@ -34,6 +35,7 @@ class NewDeadlineModalForm(BaseModalForm):
|
||||
label_suffix="",
|
||||
required=True,
|
||||
help_text=_("Select date"),
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
@ -9,6 +9,7 @@ from django import forms
|
||||
from django.utils.translation import pgettext_lazy as _con, gettext_lazy as _
|
||||
|
||||
from konova.forms.modals import RemoveModalForm, BaseModalForm
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import PAYMENT_EDITED
|
||||
|
||||
|
||||
@ -33,6 +34,7 @@ class NewPaymentForm(BaseModalForm):
|
||||
label=_("Due on"),
|
||||
label_suffix=_(""),
|
||||
required=False,
|
||||
validators=[validators.reasonable_date],
|
||||
help_text=_("Due on which date"),
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
|
@ -9,6 +9,7 @@ from dal import autocomplete
|
||||
from django import forms
|
||||
|
||||
from konova.forms.base_form import BaseForm
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import EDITED_GENERAL_DATA
|
||||
from user.models import User
|
||||
from django.db import transaction
|
||||
@ -175,6 +176,7 @@ class NewInterventionForm(BaseForm):
|
||||
label=_("Registration date"),
|
||||
label_suffix=_(""),
|
||||
required=False,
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
@ -187,6 +189,7 @@ class NewInterventionForm(BaseForm):
|
||||
label=_("Binding on"),
|
||||
label_suffix=_(""),
|
||||
required=False,
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
@ -11,6 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.models import RevocationDocument
|
||||
from konova.forms.modals import BaseModalForm, RemoveModalForm
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import REVOCATION_ADDED, REVOCATION_EDITED
|
||||
|
||||
|
||||
@ -19,6 +20,7 @@ class NewRevocationModalForm(BaseModalForm):
|
||||
label=_("Date"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("Date of revocation"),
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
@ -12,6 +12,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.forms.modals.base_form import BaseModalForm
|
||||
from konova.models import AbstractDocument
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import DOCUMENT_EDITED, FILE_SIZE_TOO_LARGE, FILE_TYPE_UNSUPPORTED
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
@ -34,6 +35,7 @@ class NewDocumentModalForm(BaseModalForm):
|
||||
label=_("Created on"),
|
||||
label_suffix=_(""),
|
||||
help_text=_("When has this file been created? Important for photos."),
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
@ -14,6 +14,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.forms.modals.base_form import BaseModalForm
|
||||
from konova.models import Resubmission
|
||||
from konova.utils import validators
|
||||
|
||||
|
||||
class ResubmissionModalForm(BaseModalForm):
|
||||
@ -21,6 +22,7 @@ class ResubmissionModalForm(BaseModalForm):
|
||||
label_suffix=_(""),
|
||||
label=_("Date"),
|
||||
help_text=_("When do you want to be reminded?"),
|
||||
validators=[validators.reasonable_date],
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
|
28
konova/utils/validators.py
Normal file
28
konova/utils/validators.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: ksp-servicestelle@sgdnord.rlp.de
|
||||
Created on: 17.05.23
|
||||
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def reasonable_date(value):
|
||||
""" Validator which checks that no dates like "01.01.1" can be entered
|
||||
|
||||
Args:
|
||||
value ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
min_date = datetime.fromisoformat("1950-01-01").date()
|
||||
if value < min_date:
|
||||
raise ValidationError(
|
||||
_("This date is unrealistic. Please enter the correct date (>1950)."),
|
||||
params={"value": value},
|
||||
)
|
Binary file not shown.
@ -5,7 +5,7 @@
|
||||
#
|
||||
#: compensation/filters/eco_account.py:21
|
||||
#: compensation/forms/modals/compensation_action.py:82
|
||||
#: compensation/forms/modals/deadline.py:50
|
||||
#: compensation/forms/modals/deadline.py:52
|
||||
#: compensation/forms/modals/payment.py:23
|
||||
#: compensation/forms/modals/payment.py:34
|
||||
#: compensation/forms/modals/payment.py:50
|
||||
@ -43,7 +43,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-03-07 07:09+0100\n"
|
||||
"POT-Creation-Date: 2023-05-17 12:42+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"
|
||||
@ -72,7 +72,7 @@ msgstr "Einträge erstellt bis..."
|
||||
#: analysis/forms.py:49 compensation/forms/mixins.py:21
|
||||
#: compensation/templates/compensation/detail/eco_account/view.html:59
|
||||
#: compensation/templates/compensation/report/eco_account/report.html:16
|
||||
#: compensation/utils/quality.py:112 ema/templates/ema/detail/view.html:49
|
||||
#: compensation/utils/quality.py:113 ema/templates/ema/detail/view.html:49
|
||||
#: ema/templates/ema/report/report.html:16 ema/utils/quality.py:26
|
||||
#: intervention/forms/intervention.py:104
|
||||
#: intervention/templates/intervention/detail/view.html:56
|
||||
@ -398,7 +398,7 @@ msgstr "Kompensation XY; Flur ABC"
|
||||
|
||||
#: compensation/forms/compensation.py:56
|
||||
#: compensation/forms/modals/compensation_action.py:81
|
||||
#: compensation/forms/modals/deadline.py:49
|
||||
#: compensation/forms/modals/deadline.py:51
|
||||
#: compensation/forms/modals/payment.py:49
|
||||
#: compensation/templates/compensation/detail/compensation/includes/actions.html:35
|
||||
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:39
|
||||
@ -446,7 +446,7 @@ msgstr "Neue Kompensation"
|
||||
msgid "Edit compensation"
|
||||
msgstr "Bearbeite Kompensation"
|
||||
|
||||
#: compensation/forms/eco_account.py:30 compensation/utils/quality.py:96
|
||||
#: compensation/forms/eco_account.py:30 compensation/utils/quality.py:97
|
||||
msgid "Available Surface"
|
||||
msgstr "Verfügbare Fläche"
|
||||
|
||||
@ -486,7 +486,7 @@ msgstr ""
|
||||
#: compensation/forms/mixins.py:37
|
||||
#: compensation/templates/compensation/detail/eco_account/view.html:63
|
||||
#: compensation/templates/compensation/report/eco_account/report.html:20
|
||||
#: compensation/utils/quality.py:114 ema/templates/ema/detail/view.html:53
|
||||
#: compensation/utils/quality.py:115 ema/templates/ema/detail/view.html:53
|
||||
#: ema/templates/ema/report/report.html:20 ema/utils/quality.py:28
|
||||
#: intervention/forms/intervention.py:132
|
||||
#: intervention/templates/intervention/detail/view.html:60
|
||||
@ -604,15 +604,15 @@ msgstr "Geben Sie die Daten der neuen Maßnahme ein"
|
||||
msgid "Edit action"
|
||||
msgstr "Maßnahme bearbeiten"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:21
|
||||
#: compensation/forms/modals/deadline.py:23
|
||||
msgid "Deadline Type"
|
||||
msgstr "Fristart"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:24
|
||||
#: compensation/forms/modals/deadline.py:26
|
||||
msgid "Select the deadline type"
|
||||
msgstr "Fristart wählen"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:33
|
||||
#: compensation/forms/modals/deadline.py:35
|
||||
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:36
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:36
|
||||
#: ema/templates/ema/detail/includes/deadlines.html:36
|
||||
@ -621,26 +621,30 @@ msgstr "Fristart wählen"
|
||||
msgid "Date"
|
||||
msgstr "Datum"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:36
|
||||
#: compensation/forms/modals/deadline.py:38
|
||||
msgid "Select date"
|
||||
msgstr "Datum wählen"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:51
|
||||
#: compensation/forms/modals/deadline.py:53
|
||||
#: compensation/forms/modals/payment.py:51
|
||||
#: intervention/forms/modals/revocation.py:47
|
||||
#: konova/forms/modals/document_form.py:61
|
||||
msgid "Additional comment, maximum {} letters"
|
||||
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:63
|
||||
#: compensation/forms/modals/deadline.py:65
|
||||
msgid "New deadline"
|
||||
msgstr "Neue Frist"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:64
|
||||
#: compensation/forms/modals/deadline.py:66
|
||||
msgid "Insert data for the new deadline"
|
||||
msgstr "Geben Sie die Daten der neuen Frist ein"
|
||||
|
||||
#: compensation/forms/modals/deadline.py:77
|
||||
msgid "This date is unrealistic. Please enter the correct date (>1950)."
|
||||
msgstr "Dieses Datum ist unrealistisch. Geben Sie bitte das korrekte Datum ein (>1950)."
|
||||
|
||||
#: compensation/forms/modals/deadline.py:95
|
||||
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:64
|
||||
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:62
|
||||
#: ema/templates/ema/detail/includes/deadlines.html:62
|
||||
@ -1262,13 +1266,13 @@ msgstr "Umsetzungstermin"
|
||||
msgid "Legal data"
|
||||
msgstr "Rechtliche Daten"
|
||||
|
||||
#: compensation/utils/quality.py:100
|
||||
#: compensation/utils/quality.py:101
|
||||
msgid "Deductable surface can not be larger than state surface"
|
||||
msgstr ""
|
||||
"Die abbuchbare Fläche darf die Gesamtfläche der Zielzustände nicht "
|
||||
"überschreiten"
|
||||
|
||||
#: compensation/utils/quality.py:116 ema/utils/quality.py:30
|
||||
#: compensation/utils/quality.py:117 ema/utils/quality.py:30
|
||||
#: intervention/utils/quality.py:68
|
||||
msgid "Responsible data"
|
||||
msgstr "Daten zu den verantwortlichen Stellen"
|
||||
@ -1283,7 +1287,7 @@ msgid "Compensation {} edited"
|
||||
msgstr "Kompensation {} bearbeitet"
|
||||
|
||||
#: compensation/views/compensation/compensation.py:187
|
||||
#: compensation/views/eco_account/eco_account.py:161 ema/views/ema.py:212
|
||||
#: compensation/views/eco_account/eco_account.py:161 ema/views/ema.py:220
|
||||
#: intervention/views/intervention.py:243
|
||||
msgid "Edit {}"
|
||||
msgstr "Bearbeite {}"
|
||||
@ -1306,11 +1310,11 @@ msgstr "Ökokonto {} hinzugefügt"
|
||||
msgid "Eco-Account {} edited"
|
||||
msgstr "Ökokonto {} bearbeitet"
|
||||
|
||||
#: compensation/views/eco_account/eco_account.py:268
|
||||
#: compensation/views/eco_account/eco_account.py:275
|
||||
msgid "Eco-account removed"
|
||||
msgstr "Ökokonto entfernt"
|
||||
|
||||
#: ema/forms.py:42 ema/views/ema.py:95
|
||||
#: ema/forms.py:42 ema/views/ema.py:96
|
||||
msgid "New EMA"
|
||||
msgstr "Neue EMA hinzufügen"
|
||||
|
||||
@ -1338,19 +1342,19 @@ msgstr ""
|
||||
msgid "Payment funded compensation"
|
||||
msgstr "Ersatzzahlungsmaßnahme"
|
||||
|
||||
#: ema/views/ema.py:52
|
||||
#: ema/views/ema.py:53
|
||||
msgid "EMAs - Overview"
|
||||
msgstr "EMAs - Übersicht"
|
||||
|
||||
#: ema/views/ema.py:85
|
||||
#: ema/views/ema.py:86
|
||||
msgid "EMA {} added"
|
||||
msgstr "EMA {} hinzugefügt"
|
||||
|
||||
#: ema/views/ema.py:202
|
||||
#: ema/views/ema.py:210
|
||||
msgid "EMA {} edited"
|
||||
msgstr "EMA {} bearbeitet"
|
||||
|
||||
#: ema/views/ema.py:236
|
||||
#: ema/views/ema.py:244
|
||||
msgid "EMA removed"
|
||||
msgstr "EMA entfernt"
|
||||
|
||||
@ -2095,7 +2099,8 @@ msgid ""
|
||||
"Do not forget to share your entry! Currently you are the only one having "
|
||||
"shared access."
|
||||
msgstr ""
|
||||
"Denken Sie daran Ihren Eintrag freizugeben! Aktuell haben nur Sie eine Freigabe hierauf."
|
||||
"Denken Sie daran Ihren Eintrag freizugeben! Aktuell haben nur Sie eine "
|
||||
"Freigabe hierauf."
|
||||
|
||||
#: konova/utils/message_templates.py:29
|
||||
msgid "Unsupported file type"
|
||||
@ -2270,7 +2275,7 @@ msgstr "Für Sie freigegeben - Datensatz kann bearbeitet werden"
|
||||
msgid "Access not granted"
|
||||
msgstr "Nicht freigegeben - Datensatz nur lesbar"
|
||||
|
||||
#: konova/views/home.py:80 templates/navbars/navbar.html:16
|
||||
#: konova/views/home.py:74 templates/navbars/navbar.html:16
|
||||
msgid "Home"
|
||||
msgstr "Home"
|
||||
|
||||
@ -2306,15 +2311,15 @@ msgstr "{} ist nun für Sie freigegeben"
|
||||
msgid "Share link invalid"
|
||||
msgstr "Freigabelink ungültig"
|
||||
|
||||
#: news/models.py:12
|
||||
#: news/models.py:13
|
||||
msgid "Default"
|
||||
msgstr "Standard"
|
||||
|
||||
#: news/models.py:13
|
||||
#: news/models.py:14
|
||||
msgid "Info"
|
||||
msgstr ""
|
||||
|
||||
#: news/models.py:14
|
||||
#: news/models.py:15
|
||||
msgid "Warning"
|
||||
msgstr "Warnung"
|
||||
|
||||
@ -2330,7 +2335,7 @@ msgstr "Ältere ..."
|
||||
msgid "All"
|
||||
msgstr "Alle"
|
||||
|
||||
#: news/templates/news/index.html:9 news/views.py:34
|
||||
#: news/templates/news/index.html:9 news/views.py:27
|
||||
msgid "News"
|
||||
msgstr "Neuigkeiten"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user