# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-06-10 17:57
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import main.validators
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Event',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('trigger_type', models.PositiveSmallIntegerField(choices=[(1, 'new order'), (2, 'forgotten cart'), (3, 'forgotten shop')])),
                ('create_at', models.DateTimeField(auto_now_add=True)),
                ('update_at', models.DateTimeField(auto_now=True)),
                ('context', django.contrib.postgres.fields.jsonb.JSONField(default={})),
            ],
        ),
        migrations.CreateModel(
            name='Shop',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64)),
                ('slug', models.SlugField()),
            ],
        ),
        migrations.CreateModel(
            name='Template',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('trigger_type', models.PositiveSmallIntegerField(choices=[(1, 'new order'), (2, 'forgotten cart'), (3, 'forgotten shop')])),
                ('active', models.BooleanField(default=True)),
                ('content_type', models.PositiveSmallIntegerField(choices=[(1, 'plain'), (2, 'html')], default=2)),
                ('subject', models.CharField(max_length=255, validators=[main.validators.validate_template])),
                ('body', models.TextField(blank=True, null=True, validators=[main.validators.validate_template, main.validators.validate_html])),
                ('body_template_name', models.CharField(blank=True, max_length=100, null=True, validators=[main.validators.validate_template_file])),
                ('shop', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='templates', to='main.Shop')),
            ],
            options={
                'verbose_name': 'Template',
                'verbose_name_plural': 'Templates',
            },
        ),
        migrations.CreateModel(
            name='TemplateLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('opening_uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('opening_counter', models.IntegerField(default=0)),
                ('create_at', models.DateTimeField(auto_now_add=True)),
                ('update_at', models.DateTimeField(auto_now=True)),
                ('subject', models.CharField(max_length=255)),
                ('body', models.TextField()),
                ('traceback', models.TextField(blank=True, db_index=True, null=True)),
                ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='main.Template')),
            ],
            options={
                'ordering': ['-create_at'],
                'verbose_name': 'Logs',
                'verbose_name_plural': 'Logs',
            },
        ),
        migrations.AddField(
            model_name='event',
            name='shop',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='events', to='main.Shop'),
        ),
    ]
