use profile in mass unit tag
This commit is contained in:
parent
22b2bb0b82
commit
077d300bfb
@ -13,7 +13,10 @@ class MassNode(template.Node):
|
|||||||
def render(self, context):
|
def render(self, context):
|
||||||
try:
|
try:
|
||||||
weight_kg = self.weight.resolve(context)
|
weight_kg = self.weight.resolve(context)
|
||||||
|
if context['user'].profile.lifting_units == 'i':
|
||||||
return round_to(weight_kg * decimal.Decimal("2.2046"), decimal.Decimal("0.125"))
|
return round_to(weight_kg * decimal.Decimal("2.2046"), decimal.Decimal("0.125"))
|
||||||
|
else:
|
||||||
|
return weight_kg
|
||||||
except template.VariableDoesNotExist:
|
except template.VariableDoesNotExist:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@ -10,6 +10,3 @@ class Profile(models.Model):
|
|||||||
user = models.OneToOneField(User, related_name='profile')
|
user = models.OneToOneField(User, related_name='profile')
|
||||||
|
|
||||||
lifting_units = models.CharField(max_length=1, choices=UNITS)
|
lifting_units = models.CharField(max_length=1, choices=UNITS)
|
||||||
|
|
||||||
def metric(self):
|
|
||||||
return self.lifting_units == 'm'
|
|
||||||
|
Loading…
Reference in New Issue
Block a user