# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-04-04 18:37
from __future__ import unicode_literals

from django.db import migrations

def load_tags(apps, schema_editor):
    # copy tags
    from aldryn_newsblog.models import Article as OldArticle
    from articles.models import Article as Article

    for old_article in OldArticle.objects.all():
        article = Article.objects.get(content_id=old_article.content_id)

        for tag in old_article.tags.all():
            article.tags.add(tag.name)


def unload_tags(apps, schema_editor):
    # copy tags
    from articles.models import Article as Article

    for article in Article.objects.all():
        article.tags.clear()


class Migration(migrations.Migration):

    dependencies = [
        ('articles', '0004_load_news_translated_fields'),
    ]

    operations = [
        migrations.RunPython(load_tags, unload_tags),
    ]
