# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-02 19:36
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('pcart_messaging', '0001_initial'),
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='DataCollection',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('unique_titles', models.BooleanField(default=False, help_text='If checked than Title field for the records must be unique.', verbose_name='Unique titles')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
            ],
            options={
                'verbose_name_plural': 'Data collections',
                'verbose_name': 'Data collection',
                'ordering': ['title'],
            },
        ),
        migrations.CreateModel(
            name='DataCollectionField',
            fields=[
                ('order', models.PositiveIntegerField(db_index=True, default=0, editable=False)),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255, validators=[django.core.validators.RegexValidator(message="Value may only contain the letters a-z, A-Z, digits, minus and underscores, and can't start with a digit.", regex='^[a-zA-Z\\-_][0-9a-zA-Z\\-_]*$')], verbose_name='Name')),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('field_type', models.CharField(choices=[('string', 'String'), ('email', 'Email'), ('text', 'Multiline text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('choice', 'Choice'), ('multiple_choice', 'Multiple choice'), ('file', 'File'), ('wysiwyg', 'WYSIWYG'), ('code', 'Code'), ('date', 'Date')], default='string', max_length=20, verbose_name='Field type')),
                ('choices', models.TextField(blank=True, default='', help_text='Usable for Choice type. Type choices in different lines.', verbose_name='Choices')),
                ('help_text', models.TextField(blank=True, default='', verbose_name='Help text')),
                ('required', models.BooleanField(default=False, verbose_name='Required')),
                ('admin_list_display', models.BooleanField(default=False, verbose_name='Admin list display')),
                ('collection_order', models.PositiveIntegerField(db_index=True, default=0, editable=False)),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
                ('data_collection', adminsortable.fields.SortableForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fields', to='pcart_data_collections.DataCollection', verbose_name='Data collection')),
            ],
            options={
                'verbose_name_plural': 'Data collection fields',
                'ordering': ['collection_order'],
                'verbose_name': 'Data collection field',
            },
        ),
        migrations.CreateModel(
            name='DataRecord',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(blank=True, max_length=255, verbose_name='Title')),
                ('active', models.BooleanField(default=True, verbose_name='Active')),
                ('data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default={}, verbose_name='Data')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Last change')),
                ('data_collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='records', to='pcart_data_collections.DataCollection', verbose_name='Data collection')),
            ],
            options={
                'verbose_name_plural': 'Data records',
                'verbose_name': 'Data record',
                'ordering': ['added', 'id'],
            },
        ),
        migrations.CreateModel(
            name='MailHook',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, unique=True, verbose_name='Title')),
                ('active', models.BooleanField(default=True, verbose_name='Active')),
                ('event_type', models.CharField(choices=[('new', 'New record'), ('changed', 'Changed')], default='new', max_length=25, verbose_name='Event type')),
                ('additional_emails', models.TextField(blank=True, default='', help_text='Type the emails in different lines.', verbose_name='Additional emails')),
                ('from_email', models.CharField(default='no-reply@p-cart.com', help_text='You can use {{field_name}} for insert data from data record.', max_length=255, verbose_name='From email')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Last change')),
                ('data_collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mail_hooks', to='pcart_data_collections.DataCollection', verbose_name='Data collection')),
                ('email_template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mail_hooks', to='pcart_messaging.EmailTemplate', verbose_name='Email template')),
                ('user_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mail_hooks', to='auth.Group', verbose_name='User group')),
            ],
            options={
                'verbose_name_plural': 'Mail hooks',
                'verbose_name': 'Mail hook',
                'ordering': ['title'],
            },
        ),
        migrations.CreateModel(
            name='WebForm',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, unique=True, verbose_name='Title')),
                ('fields', models.CharField(blank=True, default='', help_text='Comma separated list of field names.', max_length=255, verbose_name='Fields')),
                ('hidden_fields', models.CharField(blank=True, default='', help_text='Comma separated list of hidden fields. Must be subset of the "Fields" list.', max_length=255, verbose_name='Hidden fields')),
                ('show_captcha', models.BooleanField(default=False, verbose_name='Show captcha')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Last change')),
                ('data_collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='web_forms', to='pcart_data_collections.DataCollection', verbose_name='Data collection')),
            ],
            options={
                'verbose_name_plural': 'Web forms',
                'verbose_name': 'Web form',
                'ordering': ['title'],
            },
        ),
        migrations.AlterUniqueTogether(
            name='datacollectionfield',
            unique_together=set([('data_collection', 'name')]),
        ),
    ]
