generated from 2martens/django-template
Added meal plan
This commit is contained in:
@ -5,6 +5,7 @@ from django.contrib.auth.models import User
|
|||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
from food_planner.models import Ingredient
|
from food_planner.models import Ingredient
|
||||||
|
from food_planner.models import MealPlan
|
||||||
from food_planner.models import Pantry
|
from food_planner.models import Pantry
|
||||||
from food_planner.models import Product
|
from food_planner.models import Product
|
||||||
from food_planner.models import Profile
|
from food_planner.models import Profile
|
||||||
@ -51,3 +52,4 @@ admin.site.register(Ingredient)
|
|||||||
admin.site.register(Vendor)
|
admin.site.register(Vendor)
|
||||||
admin.site.register(Pantry, PantryAdmin)
|
admin.site.register(Pantry, PantryAdmin)
|
||||||
admin.site.register(Product)
|
admin.site.register(Product)
|
||||||
|
admin.site.register(MealPlan)
|
||||||
|
|||||||
62
food_planner/migrations/0003_mealplan.py
Normal file
62
food_planner/migrations/0003_mealplan.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Generated by Django 3.0.3 on 2020-02-23 11:49
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('food_planner', '0002_auto_20200219_1336'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MealPlan',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('friday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='friday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('friday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='friday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('friday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='friday_dinner', to='food_planner.Recipe')),
|
||||||
|
('friday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='friday_lunch', to='food_planner.Recipe')),
|
||||||
|
('friday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='friday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('monday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='monday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('monday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='monday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('monday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='monday_dinner', to='food_planner.Recipe')),
|
||||||
|
('monday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='monday_lunch', to='food_planner.Recipe')),
|
||||||
|
('monday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='monday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('saturday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='saturday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('saturday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='saturday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('saturday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='saturday_dinner', to='food_planner.Recipe')),
|
||||||
|
('saturday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='saturday_lunch', to='food_planner.Recipe')),
|
||||||
|
('saturday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='saturday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('sunday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sunday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('sunday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sunday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('sunday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sunday_dinner', to='food_planner.Recipe')),
|
||||||
|
('sunday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sunday_lunch', to='food_planner.Recipe')),
|
||||||
|
('sunday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sunday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('thursday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='thursday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('thursday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='thursday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('thursday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='thursday_dinner', to='food_planner.Recipe')),
|
||||||
|
('thursday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='thursday_lunch', to='food_planner.Recipe')),
|
||||||
|
('thursday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='thursday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('tuesday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tuesday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('tuesday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tuesday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('tuesday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tuesday_dinner', to='food_planner.Recipe')),
|
||||||
|
('tuesday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tuesday_lunch', to='food_planner.Recipe')),
|
||||||
|
('tuesday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tuesday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
('wednesday_afternoon_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wednesday_afternoon_snack', to='food_planner.Recipe')),
|
||||||
|
('wednesday_breakfast', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wednesday_breakfast', to='food_planner.Recipe')),
|
||||||
|
('wednesday_dinner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wednesday_dinner', to='food_planner.Recipe')),
|
||||||
|
('wednesday_lunch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wednesday_lunch', to='food_planner.Recipe')),
|
||||||
|
('wednesday_morning_snack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wednesday_morning_snack', to='food_planner.Recipe')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Meal plan',
|
||||||
|
'verbose_name_plural': 'Meal plans',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -1,7 +1,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.text import format_lazy
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@ -199,3 +198,88 @@ class StoredIngredient(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str.format('{amount} {unit} of {ingredient}',
|
return str.format('{amount} {unit} of {ingredient}',
|
||||||
amount=self.amount, unit=self.unit, ingredient=self.ingredient)
|
amount=self.amount, unit=self.unit, ingredient=self.ingredient)
|
||||||
|
|
||||||
|
|
||||||
|
class MealPlan(models.Model):
|
||||||
|
author = models.ForeignKey(User, models.SET_NULL, null=True)
|
||||||
|
|
||||||
|
monday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='monday_breakfast')
|
||||||
|
monday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='monday_morning_snack')
|
||||||
|
monday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='monday_lunch')
|
||||||
|
monday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='monday_afternoon_snack')
|
||||||
|
monday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='monday_dinner')
|
||||||
|
|
||||||
|
tuesday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='tuesday_breakfast')
|
||||||
|
tuesday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='tuesday_morning_snack')
|
||||||
|
tuesday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='tuesday_lunch')
|
||||||
|
tuesday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='tuesday_afternoon_snack')
|
||||||
|
tuesday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='tuesday_dinner')
|
||||||
|
|
||||||
|
wednesday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='wednesday_breakfast')
|
||||||
|
wednesday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='wednesday_morning_snack')
|
||||||
|
wednesday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='wednesday_lunch')
|
||||||
|
wednesday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='wednesday_afternoon_snack')
|
||||||
|
wednesday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='wednesday_dinner')
|
||||||
|
|
||||||
|
thursday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='thursday_breakfast')
|
||||||
|
thursday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='thursday_morning_snack')
|
||||||
|
thursday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='thursday_lunch')
|
||||||
|
thursday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='thursday_afternoon_snack')
|
||||||
|
thursday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='thursday_dinner')
|
||||||
|
|
||||||
|
friday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='friday_breakfast')
|
||||||
|
friday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='friday_morning_snack')
|
||||||
|
friday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='friday_lunch')
|
||||||
|
friday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='friday_afternoon_snack')
|
||||||
|
friday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='friday_dinner')
|
||||||
|
|
||||||
|
saturday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='saturday_breakfast')
|
||||||
|
saturday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='saturday_morning_snack')
|
||||||
|
saturday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='saturday_lunch')
|
||||||
|
saturday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='saturday_afternoon_snack')
|
||||||
|
saturday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='saturday_dinner')
|
||||||
|
|
||||||
|
sunday_breakfast = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='sunday_breakfast')
|
||||||
|
sunday_morning_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='sunday_morning_snack')
|
||||||
|
sunday_lunch = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='sunday_lunch')
|
||||||
|
sunday_afternoon_snack = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='sunday_afternoon_snack')
|
||||||
|
sunday_dinner = models.ForeignKey(Recipe, models.SET_NULL, blank=True, null=True,
|
||||||
|
related_name='sunday_dinner')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _('Meal plan')
|
||||||
|
verbose_name_plural = _('Meal plans')
|
||||||
|
|||||||
Reference in New Issue
Block a user