# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import mtp.apps.ideas.managers


def migrate_brainstormers_to_ideas(apps, schema_editor):
    """Migrate the ``Brainstormer`` and the related model to their ideas equivalent"""

    Brainstorming = apps.get_model(
        'ideas',
        'Brainstorming'
    )

    Brainstorming.objects.migrate_brainstormer_templates(
        template_model=apps.get_model(
            'brainstormers',
            'BrainstormerTemplate'
        )
    )
    Brainstorming.objects.migrate_brainstormers()


def noop_backward_func(apps, schema_editor):
    """No turning back"""

    pass


class Migration(migrations.Migration):

    dependencies = [
        ('ideas', '0001_initial'),
        ('brainstormers', '0028_remove_brainstormeractivity'),
        ('trainings', '0046_training_activity_description_nullable'),
        ('likes', '0005_use_django_extension_uuid')
    ]

    operations = [
        migrations.AlterModelManagers(
            name='brainstorming',
            managers=[
                ('objects', mtp.apps.ideas.managers.IdeasActivityManager()),
            ],
        ),
        migrations.RunPython(migrate_brainstormers_to_ideas, noop_backward_func)
    ]
