# Generated by Django 2.1.2 on 2018-11-09 15:21

from django.db import migrations


def results_cols_to_array(apps, schema_editor):
    Config = apps.get_model("evaluation", "Config")  # noqa: N806

    for config in Config.objects.all():

        extra_cols_array = []

        for title, path in config.extra_results_columns.items():
            extra_cols_array.append({"title": title, "path": path})

        config.extra_results_columns = extra_cols_array
        config.save()


def results_cols_to_dict(apps, schema_editor):
    Config = apps.get_model("evaluation", "Config")  # noqa: N806
    for config in Config.objects.all():

        extra_cols_dict = {}

        for col in config.extra_results_columns:
            extra_cols_dict[col["title"]] = col["path"]

        config.extra_results_columns = extra_cols_dict
        config.save()


class Migration(migrations.Migration):

    dependencies = [("evaluation", "0016_auto_20181109_1535")]

    operations = [
        migrations.RunPython(results_cols_to_array, results_cols_to_dict)
    ]
