Fixed habit creation for lists
This commit is contained in:
parent
979bfc24f9
commit
32b0d3017c
8
app.py
8
app.py
@ -187,6 +187,12 @@ def habit_create():
|
|||||||
if unit not in ['Tag', 'Woche', 'Monat', 'Jahr']:
|
if unit not in ['Tag', 'Woche', 'Monat', 'Jahr']:
|
||||||
errors['unit'] = 'Die Einheit ist ungültig.'
|
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:
|
if errors:
|
||||||
return render_template(
|
return render_template(
|
||||||
'habit.html',
|
'habit.html',
|
||||||
@ -212,7 +218,7 @@ def habit_create():
|
|||||||
unit = 1
|
unit = 1
|
||||||
|
|
||||||
# Save habit to database
|
# 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
|
# Back to index
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user