bia-fitness/inventory/models.py

28 lines
643 B
Python
Raw Normal View History

2015-04-10 18:19:12 +00:00
from django.db import models
2015-04-10 21:31:12 +00:00
from common import remove_exponent, to_lb
2015-04-10 18:19:12 +00:00
class Bar(models.Model):
name = models.CharField(max_length=100)
weight_kg = models.DecimalField(max_digits=7, decimal_places=3)
def __str__(self):
2015-04-10 21:31:12 +00:00
return '{} ({}kg / {}lb)'.format(self.name, remove_exponent(self.weight_kg),
self.weight_lb)
2015-04-10 18:19:12 +00:00
@property
def weight_lb(self):
return to_lb(self.weight_kg)
class Lift(models.Model):
name = models.CharField(max_length=200)
2015-04-10 21:31:12 +00:00
@property
def display_name(self):
return self.name
2015-04-10 18:19:12 +00:00
def __str__(self):
return self.name