text: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.15 on 2020-04-21 07:11
  from __future__ import unicode_literals
  
  from django.db import migrations, connection
  from bluebottle.utils.utils import get_languages
  from django.utils.translation import activate, _trans, gettext as _
  from tenant_extras.middleware import tenant_translation
  
  
  def migrate_content(apps, schema_editor):
      Client = apps.get_model('clients', 'Client')
      tenant = Client.objects.get(schema_name=connection.tenant.schema_name)
      languages = get_languages()
  
      Category = apps.get_model('categories', 'Category')
      CategoryTranslation = apps.get_model('categories', 'CategoryTranslation')
  
      for block in Category.objects.all():
          for (language, _long_language) in languages:
              activate(language)
              _trans._active.value = tenant_translation(language, tenant.client_name)
              CategoryTranslation.objects.create(
                  master_id=block.pk,
                  language_code=language,
                  title=block.title_old,
                  description=block.description_old
              )
  
      CategoryContent = apps.get_model('categories', 'CategoryContent')
      CategoryContentTranslation = apps.get_model('categories', 'CategoryContentTranslation')
  
      for block in CategoryContent.objects.all():
          for (language, _long_language) in languages:
              activate(language)
              _trans._active.value = tenant_translation(language, tenant.client_name)
              CategoryContentTranslation.objects.create(
                  master_id=block.pk,
                  language_code=language,
                  title=block.title_old,
                  description=block.description_old,
                  link_url=block.link_url_old,
                  link_text=block.link_text_old,
              )
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('categories', '0009_translate_content_blocks'),
      ]
  
      operations = [
          migrations.RunPython(migrate_content, migrations.RunPython.noop)
      ]
  