# Generated by Django 2.0.2 on 2018-02-12 00:30

from django.db import migrations


def data_migration(apps, schema_editor):
    Officer = apps.get_model('api', 'Officer')
    fs = Officer.objects.filter(
        group__isnull=True,
        organization__isnull=False,
        organization__kind=30,
        organization__status__gt=0,
    )
    for f in fs:
        g = f.organization.groups.filter(
            kind=32
        ).latest('status')
        f.group = g
        f.save()
    return


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0074_auto_20180211_1356'),
    ]

    operations = [
        migrations.RunPython(data_migration),
    ]

patch officers