Added calories to profile and converted nutritional data to decimal fields

This commit is contained in:
2020-02-23 13:16:25 +01:00
parent 99ea1a8060
commit 863f9c6ce1
2 changed files with 115 additions and 24 deletions

View File

@ -0,0 +1,73 @@
# Generated by Django 3.0.3 on 2020-02-23 12:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('food_planner', '0004_recipe_calories'),
]
operations = [
migrations.AddField(
model_name='profile',
name='daily_calories_demand',
field=models.DecimalField(decimal_places=2, default=2000.0, help_text='At most this amount of kilo calories is needed per day', max_digits=6, verbose_name='Daily kilo calories demand'),
),
migrations.AlterField(
model_name='profile',
name='daily_carbohydrate_demand',
field=models.DecimalField(decimal_places=2, default=150.0, help_text='At most this amount of carbohydrates is needed per day', max_digits=5, verbose_name='Daily carbohydrate demand'),
),
migrations.AlterField(
model_name='profile',
name='daily_fat_demand',
field=models.DecimalField(decimal_places=2, default=117.0, help_text='At most this amount of fat is needed per day', max_digits=5, verbose_name='Daily fat demand'),
),
migrations.AlterField(
model_name='profile',
name='daily_protein_demand',
field=models.DecimalField(decimal_places=2, default=90.0, help_text='At most this amount of protein should be eaten per day', max_digits=5, verbose_name='Daily protein demand'),
),
migrations.AlterField(
model_name='profile',
name='daily_roughage_demand',
field=models.DecimalField(decimal_places=2, default=30.0, help_text='At least this amount of roughage should be eaten per day', max_digits=5, verbose_name='Daily roughage demand'),
),
migrations.AlterField(
model_name='profile',
name='daily_sugar_demand',
field=models.DecimalField(decimal_places=2, default=25.0, help_text='At most this amount of sugar is needed per day', max_digits=5, verbose_name='Daily sugar demand'),
),
migrations.AlterField(
model_name='recipe',
name='calories',
field=models.DecimalField(decimal_places=2, help_text='How many kilo calories are contained in one portion?', max_digits=6, verbose_name='Kilo Calories'),
),
migrations.AlterField(
model_name='recipe',
name='carbohydrates',
field=models.DecimalField(decimal_places=2, help_text='How much carbohydrates does one portion contain?', max_digits=5, verbose_name='Carbohydrates'),
),
migrations.AlterField(
model_name='recipe',
name='fat',
field=models.DecimalField(decimal_places=2, help_text='How much fat does one portion contain?', max_digits=5, verbose_name='Fat'),
),
migrations.AlterField(
model_name='recipe',
name='protein',
field=models.DecimalField(decimal_places=2, help_text='How much protein does one portion contain?', max_digits=5, verbose_name='Protein'),
),
migrations.AlterField(
model_name='recipe',
name='roughage',
field=models.DecimalField(decimal_places=2, help_text='How much roughage does one portion contain?', max_digits=5, verbose_name='Roughage'),
),
migrations.AlterField(
model_name='recipe',
name='sugar',
field=models.DecimalField(decimal_places=2, help_text='How much sugar does one portion contain?', max_digits=5, verbose_name='Sugar'),
),
]

View File

@ -17,24 +17,42 @@ MEASUREMENT_UNITS = [('KG', 'kg'),
class Profile(models.Model):
user = models.OneToOneField(User, models.CASCADE)
daily_fat_demand = models.PositiveIntegerField(_('Daily fat demand'),
daily_calories_demand = models.DecimalField(_('Daily kilo calories demand'),
help_text=_('At most this amount of kilo calories is needed per day'),
default=2000.00,
decimal_places=2,
max_digits=6)
daily_fat_demand = models.DecimalField(_('Daily fat demand'),
help_text=_('At most this amount of fat is needed per day'),
default=117)
daily_carbohydrate_demand = models.PositiveIntegerField(
default=117.00,
decimal_places=2,
max_digits=5)
daily_carbohydrate_demand = models.DecimalField(
_('Daily carbohydrate demand'),
help_text=_('At most this amount of carbohydrates is needed per day'),
default=150)
daily_sugar_demand = models.PositiveIntegerField(_('Daily sugar demand'),
default=150.00,
decimal_places=2,
max_digits=5,
)
daily_sugar_demand = models.DecimalField(_('Daily sugar demand'),
help_text=_('At most this amount of sugar is needed per day'),
default=25)
daily_roughage_demand = models.PositiveIntegerField(
default=25.00,
decimal_places=2,
max_digits=5)
daily_roughage_demand = models.DecimalField(
_('Daily roughage demand'),
help_text=_('At least this amount of roughage should be eaten per day'),
default=30)
daily_protein_demand = models.PositiveIntegerField(
default=30.00,
decimal_places=2,
max_digits=5
)
daily_protein_demand = models.DecimalField(
_('Daily protein demand'),
help_text=_('At most this amount of protein should be eaten per day'),
default=90)
default=90.00,
decimal_places=2,
max_digits=5,
)
class Meta:
verbose_name = _('Profile')
@ -82,17 +100,17 @@ class Recipe(models.Model):
('EXP', _('Expert'))
])
calories = models.PositiveIntegerField(_('Calories'),
help_text=_('How many calories are contained in one portion?'))
fat = models.PositiveIntegerField(_('Fat'),
calories = models.DecimalField(_('Kilo Calories'), decimal_places=2, max_digits=6,
help_text=_('How many kilo calories are contained in one portion?'))
fat = models.DecimalField(_('Fat'), decimal_places=2, max_digits=5,
help_text=_('How much fat does one portion contain?'))
carbohydrates = models.PositiveIntegerField(_('Carbohydrates'),
carbohydrates = models.DecimalField(_('Carbohydrates'), decimal_places=2, max_digits=5,
help_text=_('How much carbohydrates does one portion contain?'))
sugar = models.PositiveIntegerField(_('Sugar'),
sugar = models.DecimalField(_('Sugar'), decimal_places=2, max_digits=5,
help_text=_('How much sugar does one portion contain?'))
roughage = models.PositiveIntegerField(_('Roughage'),
roughage = models.DecimalField(_('Roughage'), decimal_places=2, max_digits=5,
help_text=_('How much roughage does one portion contain?'))
protein = models.PositiveIntegerField(_('Protein'),
protein = models.DecimalField(_('Protein'), decimal_places=2, max_digits=5,
help_text=_('How much protein does one portion contain?'))
class Meta: