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

from django.db import migrations


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

    for tp in tps:
        dirs.filter(
            pootle_path__startswith=tp.pootle_path).update(tp=tp)


class Migration(migrations.Migration):

    dependencies = [
        ('pootle_app', '0011_directory_tp'),
    ]

    operations = [
        migrations.RunPython(set_directory_tp),
    ]
