diff --git a/app.py b/app.py index ef87529..a5e8bb4 100644 --- a/app.py +++ b/app.py @@ -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'))