bia-fitness/inventory/models.py

25 lines
634 B
Python
Raw Permalink 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)
weight_lb = models.DecimalField(max_digits=7, decimal_places=3)
2015-04-10 18:19:12 +00:00
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
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