Add weight record modeling
[climbing.kerkeslager.com] / src / nutrition / models.py
index 67ccd61..03840fb 100644 (file)
@@ -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,
+        )