Fixed habit creation for lists

This commit is contained in:
Verox001 2024-02-13 10:07:22 +01:00
parent 979bfc24f9
commit 32b0d3017c

8
app.py
View File

@ -187,6 +187,12 @@ def habit_create():
if unit not in ['Tag', 'Woche', 'Monat', 'Jahr']:
errors['unit'] = 'Die Einheit ist ungültig.'
# check if list_id is an int
try:
list_id = int(list_id)
except ValueError:
errors['list_query'] = 'Die Anzahl muss eine Zahl sein.'
if errors:
return render_template(
'habit.html',
@ -212,7 +218,7 @@ def habit_create():
unit = 1
# Save habit to database
habit = Habit.create(current_user.id, name, times, note, unit)
habit = Habit.create(list_id, name, times, note, unit)
# Back to index
return redirect(url_for('index'))