mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-31 20:00:38 -05:00
food inherit attributes
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
# Generated by Django 3.2.7 on 2021-10-01 22:34
|
||||
|
||||
import datetime
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.utils.timezone import utc
|
||||
|
||||
from django_scopes import scopes_disabled
|
||||
from cookbook.models import ShoppingListEntry
|
||||
|
||||
from cookbook.models import FoodInheritField, ShoppingListEntry
|
||||
|
||||
|
||||
def delete_orphaned_sle(apps, schema_editor):
|
||||
@@ -16,6 +17,15 @@ def delete_orphaned_sle(apps, schema_editor):
|
||||
ShoppingListEntry.objects.filter(shoppinglist=None).delete()
|
||||
|
||||
|
||||
def create_inheritfields(apps, schema_editor):
|
||||
FoodInheritField.objects.create(name='Supermarket Category', field='supermarket_category')
|
||||
FoodInheritField.objects.create(name='Ignore Shopping', field='ignore_shopping')
|
||||
FoodInheritField.objects.create(name='Diet', field='diet')
|
||||
FoodInheritField.objects.create(name='Substitute', field='substitute')
|
||||
FoodInheritField.objects.create(name='Substitute Children', field='substitute_children')
|
||||
FoodInheritField.objects.create(name='Substitute Siblings', field='substitute_siblings')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@@ -25,4 +35,5 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(delete_orphaned_sle),
|
||||
migrations.RunPython(create_inheritfields),
|
||||
]
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# Generated by Django 3.2.7 on 2021-10-14 22:36
|
||||
|
||||
import cookbook.models
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0161_alter_shoppinglistentry_list_recipe'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='FoodParentIgnore',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('field', models.CharField(max_length=32, unique=True)),
|
||||
('name', models.CharField(max_length=64, unique=True)),
|
||||
],
|
||||
bases=(models.Model, cookbook.models.PermissionModelMixin),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='food',
|
||||
name='child_inherit',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='userpreference',
|
||||
name='food_inherit',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='userpreference',
|
||||
name='mealplan_autoinclude_related',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='food',
|
||||
name='ignore_parent',
|
||||
field=models.ManyToManyField(blank=True, related_name='ignore_parent', to='cookbook.FoodParentIgnore'),
|
||||
),
|
||||
]
|
||||
@@ -1,24 +0,0 @@
|
||||
from cookbook.models import FoodParentIgnore
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_ignorefields(apps, schema_editor):
|
||||
FoodParentIgnore.objects.create(name='Supermarket Category', field='name')
|
||||
FoodParentIgnore.objects.create(name='Ignore Shopping', field='ignore_shopping')
|
||||
FoodParentIgnore.objects.create(name='Diet', field='diet')
|
||||
FoodParentIgnore.objects.create(name='Substitute', field='substitute')
|
||||
FoodParentIgnore.objects.create(name='Substitute Children', field='substitute_children')
|
||||
FoodParentIgnore.objects.create(name='Substitute Siblings', field='substitute_siblings')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0162_food_inherit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
create_ignorefields
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user