Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add data migration for settings and logs
Roland Geider783165571d6f
diff --git a/wger/manager/migrations/0007_auto_20160311_2258.py b/wger/manager/migrations/0007_auto_20160311_2258.pynew file mode 100644index 000000000..c9f048b78--- /dev/null+++ b/wger/manager/migrations/0007_auto_20160311_2258.py@@ -0,0 +1,37 @@+# -*- coding: utf-8 -*-+from __future__ import unicode_literals++from django.db import migrations, models+++def convert_logs(apps, schema_editor):+ '''+ Adds a unit to users who have imperial units in the profile+ '''++ WorkoutLog = apps.get_model('manager', 'WorkoutLog')+ UserProfile = apps.get_model('core', 'UserProfile')++ for profile in UserProfile.objects.filter(weight_unit='lb'):+ WorkoutLog.objects.filter(user=profile.user).update(weight_unit=2)+++def convert_settings(apps, schema_editor):+ '''+ Adds a unit to workout settings that have 99 for 'until failure'+ '''++ Setting = apps.get_model('manager', 'Setting')+ Setting.objects.filter(reps=99).update(reps=1, repetition_unit=2)+++class Migration(migrations.Migration):++ dependencies = [+ ('manager', '0006_auto_20160303_2138'),+ ]++ operations = [+ migrations.RunPython(convert_logs, reverse_code=migrations.RunPython.noop),+ migrations.RunPython(convert_settings, reverse_code=migrations.RunPython.noop),+ ]