Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use property to check for use of metric units

Roland Geider670f94ed21fd
diff --git a/wger/core/models.py b/wger/core/models.py
index 214cc9dc7..6f6f175f0 100644
--- a/wger/core/models.py
+++ b/wger/core/models.py
@@ -348,7 +348,7 @@ by the US Department of Agriculture. It is extremely complete, with around
if not self.weight or not self.height:
return 0
- weight = self.weight if self.weight_unit == 'kg' else AbstractWeight(self.weight, 'lb').kg
+ weight = self.weight if self.use_metric else AbstractWeight(self.weight, 'lb').kg
return weight / (self.height / decimal.Decimal(100) *
self.height / decimal.Decimal(100.0))
@@ -359,7 +359,7 @@ by the US Department of Agriculture. It is extremely complete, with around
Currently only the Mifflin-St.Jeor formula is supported
'''
factor = 5 if self.gender == self.GENDER_MALE else -161
- weight = self.weight if self.weight_unit == 'kg' else AbstractWeight(self.weight, 'lb').kg
+ weight = self.weight if self.use_metric else AbstractWeight(self.weight, 'lb').kg
try:
rate = ((10 * weight) # in kg
diff --git a/wger/manager/templatetags/wger_extras.py b/wger/manager/templatetags/wger_extras.py
index e546a7ba2..b6c78b07b 100644
--- a/wger/manager/templatetags/wger_extras.py
+++ b/wger/manager/templatetags/wger_extras.py
@@ -141,7 +141,7 @@ def trans_weight_unit(unit, user=None):
to False, metric is used
:return: translated unit
'''
- if not user or user.userprofile.weight_unit == 'kg':
+ if not user or user.userprofile.use_metric:
if unit == 'kg':
return _('kg')
if unit == 'g':