bia-fitness/inventory/migrations/3000_initial_data.py

55 lines
1.4 KiB
Python
Raw Normal View History

2015-04-10 19:13:39 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def make_bars(apps, schema_editor):
Bar = apps.get_model('inventory', 'Bar')
Bar.objects.bulk_create([
2015-04-10 21:30:35 +00:00
Bar(id=1, name="Men's Olympic", weight_kg='20'),
Bar(id=2, name="Women's Olympic", weight_kg='15'),
2015-04-10 19:13:39 +00:00
])
def reverse_bars(apps, schema_editor):
Bar = apps.get_model('inventory', 'Bar')
Bar.objects.all().delete()
def make_lifts(apps, schema_editor):
Lift = apps.get_model('inventory', 'Lift')
Lift.objects.bulk_create([
# bodybuilding.com links?
Lift(name="Barbell Bench Press"),
Lift(name="Barbell Curl"),
Lift(name="Barbell Deadlift"),
Lift(name="Barbell Squat"),
Lift(name="Barbell Front Squat"),
Lift(name="Barbell Deadlift"),
Lift(name="Standing Overhead Press"),
Lift(name="Barbell Row"),
Lift(name="Pull Up"),
Lift(name="Chin Up"),
Lift(name="Push Up"),
Lift(name="Dumbbell Curl"),
])
def reverse_lifts(apps, schema_editor):
Lift = apps.get_model('inventory', 'Lift')
Lift.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('inventory', '0001_initial'),
]
operations = [
migrations.RunPython(make_bars, reverse_code=reverse_bars),
migrations.RunPython(make_lifts, reverse_code=reverse_lifts),
]