X-Git-Url: https://code.kerkeslager.com/?p=climbing.kerkeslager.com;a=blobdiff_plain;f=src%2Fnutrition%2Fmodels.py;h=03840fbb5484aba594871801f3c68b0111ad23b4;hp=71a836239075aa6e6e4ecb700e9c42c95c022d91;hb=af1a3a283688e74a6e7868395cf2a507dcd2e0f4;hpb=a61e6c6f81f4b3b226cdc232272f2cea3a129c2a diff --git a/src/nutrition/models.py b/src/nutrition/models.py index 71a8362..03840fb 100644 --- a/src/nutrition/models.py +++ b/src/nutrition/models.py @@ -1,3 +1,27 @@ +from django.contrib.auth.models import User from django.db import models -# Create your models here. +class Food(models.Model): + name = models.CharField(max_length=64) + brand = models.CharField(max_length=64) + calories = models.PositiveIntegerField() + + 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, + )