# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2020-01-10 14:55
from __future__ import unicode_literals

from django.db import migrations


def create_download_description(apps, schema_editor):
    DownloadDescriptionLabel = apps.get_model("emgapi", "DownloadDescriptionLabel")
    downloads = (
        ("Phylum level taxonomies UNITE (TSV)", "Phylum level taxonomies UNITE"),
        ("Phylum level taxonomies ITSoneDB (TSV)", "Phylum level taxonomies ITSoneDB"),
        ("Taxonomic assignments UNITE (TSV)", "Taxonomic assignments UNITE"),
        ("Taxonomic assignments ITSoneDB (TSV)", "Taxonomic assignments ITSoneDB"),
    )
    _downloads = list()
    for d in downloads:
        _downloads.append(
            DownloadDescriptionLabel(
                description=d[0],
                description_label=d[1]
            )
        )
    DownloadDescriptionLabel.objects.bulk_create(_downloads)


def create_group_types(apps, schema_editor):
    DownloadGroupType = apps.get_model("emgapi", "DownloadGroupType")
    group_types = (
        "Taxonomic analysis ITS",
        "Taxonomic analysis ITSoneDB",
        "Taxonomic analysis UNITE",
        "Pathways and Systems",
        # TODO: Do we need sub groups for the function and pathways
    )
    _groups = list()
    for group_type in group_types:
        _groups.append(
            DownloadGroupType(group_type=group_type)
        )
    DownloadGroupType.objects.bulk_create(_groups)


class Migration(migrations.Migration):
    dependencies = [
        ('emgapi', '0018_auto_20191105_1052'),
    ]

    operations = [
        migrations.RunPython(create_download_description),
        migrations.RunPython(create_group_types)
    ]

Work in progress. Creating new data migration.