# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-16 08:51
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):
    def forwards_func(apps, schema_editor):
        NewsItem = apps.get_model("core", "NewsItem")
        CommsItem = apps.get_model("comms", "NewsItem")

        db_alias = schema_editor.connection.alias
        news_items = NewsItem.objects.using(db_alias).all()

        for item in news_items:
            comms_item = CommsItem(
                content_type=item.content_type,
                object_id=item.object_id,
                title=item.title,
                body=item.body,
                posted=item.posted,
                posted_by=item.posted_by,
                start_display=item.start_display,
                end_display=item.end_display,
                sequence=item.sequence,
                large_image_file=item.large_image_file,
            )
            comms_item.save()

    def reverse_func(apps, schema_editor):
        pass

    dependencies = [
        ("core", "0004_auto_20170813_1302"),
    ]

    operations = [
        migrations.RunPython(forwards_func, reverse_func),
    ]
