use profile in mass unit tag

This commit is contained in:
James Turk 2015-04-07 13:04:48 -04:00
parent 22b2bb0b82
commit 077d300bfb
2 changed files with 4 additions and 4 deletions

View File

@ -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 ''

View File

@ -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'