Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Set initial value for weight units

Roland Geider409868f94d09
diff --git a/wger/manager/views/log.py b/wger/manager/views/log.py
index 66eefbcc8..263f8fbcc 100644
--- a/wger/manager/views/log.py
+++ b/wger/manager/views/log.py
@@ -224,7 +224,10 @@ def add(request, pk):
else:
# Initialise the formset with a queryset that won't return any objects
# (we only add new logs here and that seems to be the fastest way)
- formset = WorkoutLogFormSet(queryset=WorkoutLog.objects.none())
+ user_weight_unit = 1 if request.user.userprofile.use_metric else 2
+ formset = WorkoutLogFormSet(queryset=WorkoutLog.objects.none(),
+ initial=[{'weight_unit': user_weight_unit,
+ 'repetition_unit': 1} for x in range(0, total_sets)])
dateform = HelperDateForm(initial={'date': datetime.date.today()})