Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add unit to the log table as well

Roland Geiderbf9449a9b8b8
diff --git a/wger/core/migrations/0008_auto_20160113_1018.py b/wger/core/migrations/0008_auto_20160113_1018.py
new file mode 100644
index 000000000..556d2ccb7
--- /dev/null
+++ b/wger/core/migrations/0008_auto_20160113_1018.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0007_settingunit'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='settingunit',
+ options={'ordering': ['name']},
+ ),
+ ]
diff --git a/wger/manager/migrations/0006_auto_20160113_1018.py b/wger/manager/migrations/0006_auto_20160113_1018.py
new file mode 100644
index 000000000..788b37779
--- /dev/null
+++ b/wger/manager/migrations/0006_auto_20160113_1018.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.core.validators
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0008_auto_20160113_1018'),
+ ('manager', '0005_auto_20160107_1852'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='workoutlog',
+ name='unit',
+ field=models.ForeignKey(verbose_name='Unit', to='core.SettingUnit', default=1),
+ ),
+ migrations.AlterField(
+ model_name='setting',
+ name='reps',
+ field=models.IntegerField(verbose_name='Amount', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]),
+ ),
+ migrations.AlterField(
+ model_name='setting',
+ name='unit',
+ field=models.ForeignKey(verbose_name='Unit', to='core.SettingUnit', default=1),
+ ),
+ ]
diff --git a/wger/manager/models.py b/wger/manager/models.py
index 612b2c6de..4ec2b0495 100644
--- a/wger/manager/models.py
+++ b/wger/manager/models.py
@@ -654,8 +654,21 @@ class WorkoutLog(models.Model):
workout = models.ForeignKey(Workout,
verbose_name=_('Workout'))
+ unit = models.ForeignKey(SettingUnit,
+ verbose_name=_('Unit'),
+ default=1)
+ '''
+ The unit of the log. This can be e.g. a repetition, a minute, etc.
+ '''
+
reps = models.IntegerField(verbose_name=_('Repetitions'),
validators=[MinValueValidator(0)])
+ '''
+ Amount of repetitions, minutes, etc.
+
+ Note that since adding the unit field, the name is no longer correct, but is
+ kept for compatibility reasons (specially for the REST API).
+ '''
weight = models.DecimalField(decimal_places=2,
max_digits=5,