bia-fitness/lifting/models.py
2015-04-12 13:40:03 -04:00

36 lines
1.1 KiB
Python

from django.db import models
from django.contrib.auth.models import User
from django.contrib.postgres.fields import ArrayField
from inventory.models import Lift, Bar
SET_TYPES = (
('warmup', 'Warmup'),
('planned', 'Planned'),
)
UNITS = (
('m', 'Metric (kg)'),
('i', 'Imperial (lb)'),
)
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, default=1)
plate_pairs = ArrayField(models.DecimalField(max_digits=7, decimal_places=3),
default=['45','45','25','10','5','5','2.5','1.25'])
class Set(models.Model):
user = models.ForeignKey(User, related_name='sets')
date = models.DateField()
lift = models.ForeignKey(Lift, related_name='sets')
weight_kg = models.DecimalField(max_digits=7, decimal_places=3)
reps = models.PositiveIntegerField()
source = models.CharField(max_length=100)
def __str__(self):
return '{} - {} @ {}kg - {}'.format(self.lift, self.reps, self.weight_kg, self.date)