food logger context tips
This commit is contained in:
@@ -172,18 +172,20 @@ class HydrationGoalForm(forms.ModelForm):
|
||||
class FoodGoalForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = UserSettings
|
||||
fields = ('daily_calorie_goal', 'carbohydrate_goal_g', 'protein_goal_g', 'fat_goal_g')
|
||||
fields = ('daily_calorie_goal', 'carbohydrate_goal_g', 'protein_goal_g', 'fat_goal_g', 'fibre_goal_g')
|
||||
labels = {
|
||||
'daily_calorie_goal': 'Daily calorie goal (kcal)',
|
||||
'carbohydrate_goal_g': 'Daily carbohydrate target (g)',
|
||||
'protein_goal_g': 'Daily protein target (g)',
|
||||
'fat_goal_g': 'Daily fat target (g)',
|
||||
'fibre_goal_g': 'Daily fibre goal (g)',
|
||||
}
|
||||
widgets = {
|
||||
'daily_calorie_goal': forms.NumberInput(attrs={'min': 0, 'step': 1}),
|
||||
'carbohydrate_goal_g': forms.NumberInput(attrs={'min': 0, 'step': '0.1'}),
|
||||
'protein_goal_g': forms.NumberInput(attrs={'min': 0, 'step': '0.1'}),
|
||||
'fat_goal_g': forms.NumberInput(attrs={'min': 0, 'step': '0.1'}),
|
||||
'fibre_goal_g': forms.NumberInput(attrs={'min': 0, 'step': '0.1'}),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ class Command(BaseCommand):
|
||||
profile.carbohydrate_goal_g = Decimal('250.0')
|
||||
profile.protein_goal_g = Decimal('100.0')
|
||||
profile.fat_goal_g = Decimal('70.0')
|
||||
profile.fibre_goal_g = Decimal('40.0')
|
||||
profile.ntfy_url = ''
|
||||
profile.ntfy_enabled = False
|
||||
profile.ntfy_last_tested_at = None
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [('planner', '0019_usersettings_carbohydrate_goal_g_and_more')]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(model_name='usersettings', name='fibre_goal_g',
|
||||
field=models.DecimalField(decimal_places=1, max_digits=7, default=40,
|
||||
validators=[MinValueValidator(0)])),
|
||||
]
|
||||
@@ -124,6 +124,7 @@ class UserSettings(models.Model):
|
||||
carbohydrate_goal_g = models.DecimalField(max_digits=7, decimal_places=1, null=True, blank=True, validators=[MinValueValidator(0)])
|
||||
protein_goal_g = models.DecimalField(max_digits=7, decimal_places=1, null=True, blank=True, validators=[MinValueValidator(0)])
|
||||
fat_goal_g = models.DecimalField(max_digits=7, decimal_places=1, null=True, blank=True, validators=[MinValueValidator(0)])
|
||||
fibre_goal_g = models.DecimalField(max_digits=7, decimal_places=1, default=40, validators=[MinValueValidator(0)])
|
||||
ntfy_url = models.URLField(blank=True)
|
||||
ntfy_enabled = models.BooleanField(default=False)
|
||||
ntfy_last_tested_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
@@ -1061,6 +1061,7 @@ class DemoSeedCommandTests(TestCase):
|
||||
self.assertEqual(profile.carbohydrate_goal_g, 250)
|
||||
self.assertEqual(profile.protein_goal_g, 100)
|
||||
self.assertEqual(profile.fat_goal_g, 70)
|
||||
self.assertEqual(profile.fibre_goal_g, 40)
|
||||
self.assertFalse(profile.ntfy_enabled)
|
||||
today = localdate_for_user(demo)
|
||||
self.assertEqual(FoodLogEntry.objects.filter(user=demo, date=today).count(), 6)
|
||||
|
||||
Reference in New Issue
Block a user