# Generated by Django 3.2.13 on 2022-09-08 15:17

from django.db import migrations

LANGUAGE_COMMUNICATION = 'language_communication'
SOCIETY = 'society'
INTERDISCIPLINARY = 'interdisciplinary'

CATEGORY_CHOICES = (
    (LANGUAGE_COMMUNICATION, '#DAA009', '#FFF5D9', 'Sprache & Kommunikation'),
    (SOCIETY, '#0F7CAC', '#DBEEF6', 'Gesellschaft'),
    (INTERDISCIPLINARY, '#99B53E', '#F3F9E3', 'Überfachliche Instrumente'),
)

def create_categories(apps, schema_editor):
    InstrumentCategory = apps.get_model('basicknowledge', 'InstrumentCategory')
    InstrumentType = apps.get_model('basicknowledge', 'InstrumentType')
    for code, foreground, background, category in CATEGORY_CHOICES:
        instrument_category = InstrumentCategory.objects.create(name=category, background=background, foreground=foreground)
        InstrumentType.objects.filter(category=code).update(new_category=instrument_category)


class Migration(migrations.Migration):

    dependencies = [
        ('basicknowledge', '0019_auto_20220913_0820'),
    ]

    operations = [
        migrations.RunPython(create_categories, migrations.RunPython.noop)
    ]
