# Generated by Django 2.0 on 2018-02-20 13:56

from django.db import migrations


def copy_owner_data(apps, schema_editor):
    Secret = apps.get_model('secrets', 'Secret')
    for secret in Secret.objects.all():
        secret.allowed_groups.add(*list(secret.owner_groups.all()))
        secret.allowed_users.add(*list(secret.owner_users.all()))
        secret.notify_on_access_request.add(*list(secret.owner_users.all()))
        for group in secret.owner_groups.all():
            secret.notify_on_access_request.add(*list(group.user_set.all()))


class Migration(migrations.Migration):

    dependencies = [
        ('secrets', '0019_secret_notify_on_access_request'),
    ]

    operations = [
        migrations.RunPython(copy_owner_data),
    ]
