# Generated by Django 2.0.8 on 2021-02-01 08:45

from django.conf import settings
from django.db import migrations, models


def modify_push_trans_template(apps, schema_editor):

    if not settings.MIGRATE_INITIAL_DATA:
        return

    JobTemplate = apps.get_model('dashboard', 'JobTemplate')

    JobTemplate.objects.filter(job_template_type="pushtrans").update(
        job_template_json_str='{"job":{"ci_pipeline":"%PIPELINE_UUID%","exception":"raise","execution":"sequential",'
                              '"name":"push translations","package":"%PACKAGE_NAME%","return_type":"json",'
                              '"tasks":[{"clone":[{"name":"git repo"},{"type":"%REPO_TYPE%"},'
                              '{"branch":"%REPO_BRANCH%"},{"recursive":false}]},{"filter":[{"name":"files"},'
                              '{"ext":"PO"},{"dir":""}]},{"upload":[{"name":"Push files"},'
                              '{"target_langs":"%TARGET_LANGS%"},{"prehook":"skip"},{"posthook":"skip"},'
                              '{"import_settings":"project"},{"update":false}]}],"type":"pushtrans"}}'
    )


class Migration(migrations.Migration):

    dependencies = [
        ('dashboard', '0009_jobtemplate_job_template_derived'),
    ]

    operations = [
        migrations.AddField(
            model_name='cipipeline',
            name='ci_pipeline_last_updated',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='platform',
            name='token_api_json_str',
            field=models.TextField(blank=True, null=True, verbose_name='Auth Token JSON'),
        ),
        migrations.RunPython(modify_push_trans_template, reverse_code=migrations.RunPython.noop),
    ]
