2015-03-31 21:25:19 +00:00
|
|
|
from django.db import models
|
2015-04-01 21:57:30 +00:00
|
|
|
from django.contrib.auth.models import User
|
2015-04-01 20:29:45 +00:00
|
|
|
from django.contrib.postgres.fields import ArrayField
|
2015-03-31 21:25:19 +00:00
|
|
|
|
|
|
|
SET_TYPES = (
|
|
|
|
('warmup', 'Warmup'),
|
|
|
|
('planned', 'Planned'),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Exercise(models.Model):
|
2015-04-01 20:29:45 +00:00
|
|
|
names = ArrayField(models.CharField(max_length=200))
|
2015-03-31 21:25:19 +00:00
|
|
|
|
2015-04-07 21:33:05 +00:00
|
|
|
def display_name(self):
|
|
|
|
return self.names[0].title()
|
|
|
|
|
2015-04-01 18:43:47 +00:00
|
|
|
def __str__(self):
|
2015-04-02 22:24:34 +00:00
|
|
|
return ', '.join(self.names)
|
2015-04-01 18:43:47 +00:00
|
|
|
|
2015-03-31 21:25:19 +00:00
|
|
|
|
|
|
|
class Set(models.Model):
|
2015-04-01 21:57:30 +00:00
|
|
|
user = models.ForeignKey(User, related_name='sets')
|
2015-03-31 21:25:19 +00:00
|
|
|
date = models.DateField()
|
|
|
|
exercise = models.ForeignKey(Exercise, related_name='sets')
|
|
|
|
weight_kg = models.DecimalField(max_digits=7, decimal_places=3)
|
|
|
|
reps = models.PositiveIntegerField()
|
|
|
|
source = models.CharField(max_length=100)
|
2015-04-02 22:24:34 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '{} - {} @ {}kg - {}'.format(self.exercise, self.reps, self.weight_kg, self.date)
|