X-Git-Url: https://code.kerkeslager.com/?p=climbing.kerkeslager.com;a=blobdiff_plain;f=src%2Fnutrition%2Fmodels.py;h=03840fbb5484aba594871801f3c68b0111ad23b4;hp=67ccd61d22d86d077bca4f2294f884ba925eba35;hb=af1a3a283688e74a6e7868395cf2a507dcd2e0f4;hpb=dd2225e0e296d6c6a5f37d75242abaaeb4c3db33 diff --git a/src/nutrition/models.py b/src/nutrition/models.py index 67ccd61..03840fb 100644 --- a/src/nutrition/models.py +++ b/src/nutrition/models.py @@ -1,3 +1,4 @@ +from django.contrib.auth.models import User from django.db import models class Food(models.Model): @@ -7,3 +8,20 @@ class Food(models.Model): def __str__(self): return '{} ({})'.format(self.name, self.brand) + +WEIGHT_UNITS_CHOICES = ( + ('kgs', 'kgs'), + ('lbs', 'lbs'), +) + +class WeightRecord(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + weight = models.PositiveIntegerField() + units = models.CharField(max_length=3, choices=WEIGHT_UNITS_CHOICES) + + def __str__(self): + return '{}: {}{}'.format( + self.user.username, + self.weight, + self.units, + )