Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add a try-except block so new days without an ID don't cause trouble

Roland Geiderf8ec0d672b5c
diff --git a/manager/views.py b/manager/views.py
index 933a695b5..c4e6c1b18 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -522,8 +522,12 @@ def edit_day(request, id, day_id=None):
used_days = []
for day in workout.day_set.all():
for weekday in day.day.all():
- if day.id != int(day_id):
- used_days.append(weekday.id)
+ try:
+ if day.id != int(day_id):
+ used_days.append(weekday.id)
+ # We didnt' get a valid integer as id (perhaps because this is a new day)
+ except ValueError:
+ pass
used_days.sort()