# Generated by Django 3.0.6 on 2020-06-02 09:42

from django.db import migrations

from website.models import IngredientType, Ingredient

def create_ingredients(apps, schema_editor):
    vegetable = IngredientType.objects.get(name='légume')
    meat = IngredientType.objects.get(name='viande')
    fish = IngredientType.objects.get(name='poisson')
    fruit = IngredientType.objects.get(name='fruit')
    spice = IngredientType.objects.get(name='épice')

    vegetables = [
        'brocolis', 'chou-fleur', 'carotte', 'haricot', 'courgette', 'courge',
        'potiron', 'salade', 'endive', 'fenouil', 'topinambour'
    ]

    meats = ['boeuf', 'canard', 'lapin', 'agneau', 'poulet']

    fishes = ['anchois', 'saumon', 'truite', 'maquerau', 'lieu']

    fruits = [
        'banane', 'melon', 'pomme', 'poire', 'abricot', 'mangue', 'pêche',
        'cerise', 'mirabelle', 'raisin'
    ]

    spices = ['curry', 'cumin', 'sel', 'poivre', 'thym', 'basilic', 'menthe']

    list_ = [
        {'type': vegetable, 'list': vegetables},
        {'type': meat, 'list': meats},
        {'type': fruit, 'list': fruits},
        {'type': spice, 'list': spices},
        {'type': fish, 'list': fishes},
    ]

    for dict_ in list_:
        for item in dict_['list']:
            Ingredient.objects.create(name=item, type=dict_['type'])


class Migration(migrations.Migration):

    dependencies = [
        ('website', '0005_auto_20200602_1018'),
    ]

    operations = [
        migrations.RunPython(create_ingredients),
    ]
