Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Make user parameter for trans_weight_unit optional

Roland Geider83a29fb2b4e3
diff --git a/wger/manager/templatetags/wger_extras.py b/wger/manager/templatetags/wger_extras.py
index 97d0e4ef7..e546a7ba2 100644
--- a/wger/manager/templatetags/wger_extras.py
+++ b/wger/manager/templatetags/wger_extras.py
@@ -132,15 +132,16 @@ def auto_link_css(flavour='full', css=''):
@register.simple_tag
-def trans_weight_unit(unit, user):
+def trans_weight_unit(unit, user=None):
'''
Returns the correct (translated) weight unit
:param unit: the weight unit. Allowed values are 'kg' and 'g'
- :param user: the user object, needed to access the profile
+ :param user: the user object, needed to access the profile. If this evaluates
+ to False, metric is used
:return: translated unit
'''
- if user.userprofile.weight_unit == 'kg':
+ if not user or user.userprofile.weight_unit == 'kg':
if unit == 'kg':
return _('kg')
if unit == 'g':