# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-11-02 18:58
from __future__ import unicode_literals

from django.db import migrations


def set_directory_tp_again(apps, schema_editor):
    dirs = apps.get_model("pootle_app.Directory").objects.all()
    TP = apps.get_model("pootle_translationproject.TranslationProject")

    for tp in TP.objects.all():
        dirs.filter(pootle_path__startswith=tp.pootle_path).update(tp=tp)


class Migration(migrations.Migration):

    dependencies = [
        ('pootle_app', '0015_add_tp_path_idx'),
        ('pootle_translationproject', '0005_remove_empty_translationprojects'),
    ]

    operations = [
        migrations.RunPython(set_directory_tp_again),
    ]
