From 2f9fbc4d90513701ab8578722cebed0d2f986f56 Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 10 Apr 2015 17:30:35 -0400 Subject: [PATCH] add bar setting --- inventory/migrations/3000_initial_data.py | 4 ++-- .../0002_liftingoptions_default_bar.py | 21 +++++++++++++++++++ lifting/models.py | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 lifting/migrations/0002_liftingoptions_default_bar.py diff --git a/inventory/migrations/3000_initial_data.py b/inventory/migrations/3000_initial_data.py index ac552d9..3b19093 100644 --- a/inventory/migrations/3000_initial_data.py +++ b/inventory/migrations/3000_initial_data.py @@ -7,8 +7,8 @@ from django.db import models, migrations def make_bars(apps, schema_editor): Bar = apps.get_model('inventory', 'Bar') Bar.objects.bulk_create([ - Bar(name="Women's Olympic", weight_kg='15'), - Bar(name="Men's Olympic", weight_kg='20'), + Bar(id=1, name="Men's Olympic", weight_kg='20'), + Bar(id=2, name="Women's Olympic", weight_kg='15'), ]) diff --git a/lifting/migrations/0002_liftingoptions_default_bar.py b/lifting/migrations/0002_liftingoptions_default_bar.py new file mode 100644 index 0000000..2f6f7e5 --- /dev/null +++ b/lifting/migrations/0002_liftingoptions_default_bar.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('inventory', '3000_initial_data'), + ('lifting', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='liftingoptions', + name='default_bar', + field=models.ForeignKey(default=1, to='inventory.Bar'), + preserve_default=False, + ), + ] diff --git a/lifting/models.py b/lifting/models.py index 4cef423..c39d878 100644 --- a/lifting/models.py +++ b/lifting/models.py @@ -1,7 +1,7 @@ from django.db import models from django.contrib.auth.models import User from django.contrib.postgres.fields import ArrayField -from inventory.models import Lift +from inventory.models import Lift, Bar SET_TYPES = ( ('warmup', 'Warmup'), @@ -18,6 +18,7 @@ class LiftingOptions(models.Model): user = models.OneToOneField(User, related_name='lifting_options') lifting_units = models.CharField(max_length=1, choices=UNITS, default='i') + default_bar = models.ForeignKey(Bar) plate_pairs = ArrayField(models.DecimalField(max_digits=7, decimal_places=3), default=['45','45','25','10','5','5','2.5','1.25'])