# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-05-23 18:56
from __future__ import unicode_literals

from django.db import migrations


def fill_in_project(apps, schema_editor):
    Change = apps.get_model('trans', 'Change')

    for change in Change.objects.all():
        if change.project:
            continue
        if change.component:
            change.project = change.component.project
            change.save()
        elif change.dictionary:
            change.project = change.dictionary.project
            change.save()


class Migration(migrations.Migration):

    dependencies = [
        ('trans', '0139_source_context'),
    ]

    operations = [
        migrations.RunPython(fill_in_project),
    ]
