# -*- coding: utf-8 -*-
# Generated by Django 2.1.7 on 2019-05-16 07:34
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion

from ..models.permission import upgrade_perms, downgrade_perms


class Migration(migrations.Migration):

    dependencies = [
        ('wechat_django', '0003_usersession'),
    ]

    operations = [
        migrations.CreateModel(
            name='Template',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('template_id', models.CharField(max_length=64, verbose_name='template_id')),
                ('title', models.CharField(max_length=32, verbose_name='title')),
                ('content', models.TextField(verbose_name='content')),
                ('example', models.TextField(blank=True, null=True, verbose_name='example')),
                ('primary_industry', models.CharField(blank=True, max_length=64, null=True, verbose_name='primary industry')),
                ('deputy_industry', models.CharField(blank=True, max_length=64, null=True, verbose_name='deputy industry')),
                ('comment', models.TextField(blank=True, null=True, verbose_name='remark')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
                ('app', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='templates', to='wechat_django.WeChatApp')),
            ],
            options={
                'verbose_name': 'template',
                'verbose_name_plural': 'templates',
            },
        ),
        migrations.AlterUniqueTogether(
            name='template',
            unique_together={('app', 'template_id')},
        ),
    ]

    # 追加两个权限
    migrations.RunPython(
        lambda *args, **kwargs: upgrade_perms("template", "template_sync"),
        lambda *args, **kwargs: downgrade_perms("template", "template_sync"),
    )
