Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correct style errors

Daniel Topal161add6faa4c
diff --git a/wger/core/models.py b/wger/core/models.py
index 5e26f9039..3bea959fe 100644
--- a/wger/core/models.py
+++ b/wger/core/models.py
@@ -77,6 +77,7 @@ class Language(models.Model):
'''
return False
+
def birthdate_validator(birthdate):
'''
Checks to see if entered birthdate (datetime.date object) is
@@ -89,7 +90,8 @@ def birthdate_validator(birthdate):
raise ValidationError(
_('%(birthdate)s is not a valid birthdate'),
params={'birthdate': birthdate},
- )
+ )
+
@python_2_unicode_compatible
class UserProfile(models.Model):
@@ -221,10 +223,11 @@ by the US Department of Agriculture. It is extremely complete, with around
'''The user's age'''
birthdate = models.DateField(verbose_name=('Date of Birth'),
- help_text=_('Please use the format: mm/dd/yyyy'),
- blank=False,
- null=True,
- validators=[birthdate_validator])
+ help_text=_('Please use the format: mm/dd/yyyy'),
+ blank=False,
+ null=True,
+ validators=[birthdate_validator])
+
'''The user's date of birth'''
height = IntegerField(verbose_name=_('Height (cm)'),
diff --git a/wger/core/signals.py b/wger/core/signals.py
index 302a8f551..34c0e97be 100644
--- a/wger/core/signals.py
+++ b/wger/core/signals.py
@@ -42,13 +42,14 @@ def create_user_cache(sender, instance, created, **kwargs):
if created:
UserCache.objects.create(user=instance)
+
@receiver(pre_save, sender=UserProfile)
def set_user_age(sender, instance, **kwargs):
'''
Inputting or changing a user's birthdate will auto-update the
user's age as well if user's age has not been set
'''
- if instance.age == None and instance.birthdate != None:
+ if instance.age is None and instance.birthdate is not None:
today = datetime.date.today()
birthday = instance.birthdate
instance.age = (today.year - birthday.year