# -*- coding: utf-8 -*-
# Generated by Django A.B on YYYY-MM-DD HH:MM
from __future__ import unicode_literals

from django.db import migrations
from translation_manager.settings import get_settings
from django.conf import settings
import os


def set_rels(apps, schema_editor):
    TranslationEntry = apps.get_model('translation_manager', 'TranslationEntry')
    for row in TranslationEntry.objects.all():
        row.locale_path = os.path.relpath(settings.LOCALE_PATHS[0], get_settings('TRANSLATIONS_BASE_DIR'))
        row.save()

    TranslationBackup = apps.get_model('translation_manager', 'TranslationBackup')
    for row in TranslationBackup.objects.all():
        row.locale_path = os.path.relpath(settings.LOCALE_PATHS[0], get_settings('TRANSLATIONS_BASE_DIR'))
        row.save()


class Migration(migrations.Migration):
    dependencies = [
        ('translation_manager', '0003_auto_20160926_0856'),
    ]

    operations = [
        migrations.RunPython(set_rels),
    ]
