Self hosted FLOSS fitness/workout, nutrition and weight tracker
Make the repetition and weight unit fields optional
Roland Geider87478e9e44e4
diff --git a/wger/manager/forms.py b/wger/manager/forms.pyindex c500704c0..551771970 100644--- a/wger/manager/forms.py+++ b/wger/manager/forms.py@@ -18,6 +18,9 @@This file contains forms used in the application'''+from captcha.fields import ReCaptchaField++from django.utils.translation import ugettext as _from django.forms import (Form,MultipleHiddenInput,@@ -27,11 +30,15 @@ from django.forms import (widgets,ModelChoiceField)-from django.utils.translation import ugettext as _--from captcha.fields import ReCaptchaField-from wger.exercises.models import Exercise, ExerciseCategory+from wger.core.models import (+ RepetitionUnit,+ WeightUnit+)+from wger.exercises.models import (+ Exercise,+ ExerciseCategory+)from wger.manager.models import (WorkoutSession,Workout,@@ -130,7 +137,15 @@ class HelperDateForm(Form):class WorkoutLogForm(ModelForm):'''Helper form for a WorkoutLog.++ The repetition and weight units are defined here only to make them optional'''+ repetition_unit = ModelChoiceField(queryset=RepetitionUnit.objects.all(),+ label=_('Unit'),+ required=False)+ weight_unit = ModelChoiceField(queryset=WeightUnit.objects.all(),+ label=_('Unit'),+ required=False)class Meta:model = WorkoutLogdiff --git a/wger/manager/tests/test_weight_log.py b/wger/manager/tests/test_weight_log.pyindex 7a1b2f667..f5bff7be5 100644--- a/wger/manager/tests/test_weight_log.py+++ b/wger/manager/tests/test_weight_log.py@@ -191,18 +191,17 @@ class WeightLogOverviewAddTestCase(WorkoutManagerTestCase):'time_start': datetime.time(10, 0),'time_end': datetime.time(12, 0),'form-0-reps': 10,- 'form-0-weight': 10,'form-0-repetition_unit': 1,+ 'form-0-weight': 10,'form-0-weight_unit': 1,'form-1-reps': 10,- 'form-1-weight': 10,'form-1-repetition_unit': 1,+ 'form-1-weight': 10,'form-1-weight_unit': 1,'form-TOTAL_FORMS': 3,'form-INITIAL_FORMS': 0,'form-MAX-NUM_FORMS': 3})-count_after = WorkoutLog.objects.count()# Logged out users get a 302 redirect to login page