# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-08-29 08:45
from __future__ import unicode_literals

from django.db import migrations


def forwards(apps, schema_editor):
    CollaboratorInvite = apps.get_model('company', 'CollaboratorInvite')
    OwnershipInvite = apps.get_model('company', 'OwnershipInvite')
    CollaborationInvite = apps.get_model('company', 'CollaborationInvite')

    for invite in CollaboratorInvite.objects.all():
        CollaborationInvite.objects.create(
            uuid=invite.uuid,
            collaborator_email=invite.collaborator_email,
            company=invite.company,
            requestor=invite.requestor,
            accepted=invite.accepted,
            accepted_date=invite.accepted_date,
            role='EDITOR',
        )
    for invite in OwnershipInvite.objects.all():
        CollaborationInvite.objects.create(
            uuid=invite.uuid,
            collaborator_email=invite.new_owner_email,
            company=invite.company,
            requestor=invite.requestor,
            accepted=invite.accepted,
            accepted_date=invite.accepted_date,
            role='ADMIN',
        )


class Migration(migrations.Migration):

    dependencies = [
        ('company', '0089_auto_20190829_0845'),
    ]

    operations = [
        migrations.RunPython(forwards, reverse_code=migrations.RunPython.noop)
    ]
