From 077d300bfbedf1e765a04e832ea4daf5d23c7ffd Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 7 Apr 2015 13:04:48 -0400 Subject: [PATCH] use profile in mass unit tag --- lifting/templatetags/lifting.py | 5 ++++- profile/models.py | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lifting/templatetags/lifting.py b/lifting/templatetags/lifting.py index 479d22f..abf98be 100644 --- a/lifting/templatetags/lifting.py +++ b/lifting/templatetags/lifting.py @@ -13,7 +13,10 @@ class MassNode(template.Node): def render(self, context): try: weight_kg = self.weight.resolve(context) - return round_to(weight_kg * decimal.Decimal("2.2046"), decimal.Decimal("0.125")) + if context['user'].profile.lifting_units == 'i': + return round_to(weight_kg * decimal.Decimal("2.2046"), decimal.Decimal("0.125")) + else: + return weight_kg except template.VariableDoesNotExist: return '' diff --git a/profile/models.py b/profile/models.py index d1ac288..70d1a61 100644 --- a/profile/models.py +++ b/profile/models.py @@ -10,6 +10,3 @@ class Profile(models.Model): user = models.OneToOneField(User, related_name='profile') lifting_units = models.CharField(max_length=1, choices=UNITS) - - def metric(self): - return self.lifting_units == 'm'