diff --git a/AKSubmission/forms.py b/AKSubmission/forms.py index 83fe1fd005a4bcfe08c6024228c39dbd8d3ca528..60a3047618bd01f5c29d8cf4e9fc9c9e722498ed 100644 --- a/AKSubmission/forms.py +++ b/AKSubmission/forms.py @@ -1,4 +1,5 @@ from django import forms +from django.core.exceptions import ValidationError from AKModel.models import AK, AKOwner @@ -51,6 +52,16 @@ class AKForm(forms.ModelForm): duration = int(h) + int(m) / 60 if "," in str(duration): duration = float(duration.replace(",", ".")) + + try: + float(duration) + except ValueError: + raise ValidationError( + _('"%(duration)s" is not a valid duration'), + code='invalid', + params={'duration': duration}, + ) + return duration def clean(self): diff --git a/AKSubmission/locale/de_DE/LC_MESSAGES/django.po b/AKSubmission/locale/de_DE/LC_MESSAGES/django.po index 25f724102fd547b6e06864ebafc14117ad6279b4..7ed4db5e60541f7d6fb3eb059985a7a32e84b092 100644 --- a/AKSubmission/locale/de_DE/LC_MESSAGES/django.po +++ b/AKSubmission/locale/de_DE/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-10-24 21:34+0000\n" +"POT-Creation-Date: 2019-10-24 23:21+0000\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" @@ -17,15 +17,20 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: forms.py:38 +#: forms.py:39 msgid "Separate multiple tags with semicolon" msgstr "Mehrere Tags mit Semikolon trennen" -#: forms.py:80 +#: forms.py:60 +#, python-format +msgid "\"%(duration)s\" is not a valid duration" +msgstr "\"%(duration)s\" ist keine gültige Dauer" + +#: forms.py:94 msgid "Duration(s)" msgstr "Dauer(n)" -#: forms.py:81 +#: forms.py:95 msgid "" "Enter at least one planned duration (in hours). If your AK should have " "multiple slots, use multiple lines" @@ -188,14 +193,14 @@ msgstr "" msgid "AK successfully created" msgstr "AK erfolgreich angelegt" -#: views.py:151 +#: views.py:152 msgid "AK successfully updated" msgstr "AK erfolgreich bearbeitet" -#: views.py:208 +#: views.py:209 msgid "Person Info successfully updated" msgstr "Personen-Info erfolgreich bearbeitet" -#: views.py:220 +#: views.py:221 msgid "No user selected" msgstr "Keine Person ausgewählt"