Fixed times and unit validation

This commit is contained in:
Verox001 2024-01-19 11:05:27 +01:00
parent 8463c01133
commit 6884482e78

8
app.py
View File

@ -178,6 +178,14 @@ def habit_create():
except ValueError:
errors['times'] = 'Die Anzahl muss eine Zahl sein.'
# Check that times is greater than 0
if times <= 0:
errors['times'] = 'Die Anzahl muss größer als 0 sein.'
# Check that unit is valid
if unit not in ['Tag', 'Woche', 'Monat', 'Jahr']:
errors['unit'] = 'Die Einheit ist ungültig.'
if errors:
return render_template(
'habit.html',