# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-09 19:30
from __future__ import unicode_literals

import django.contrib.postgres.fields
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import mptt.fields
import pcart_catalog.models
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('sites', '0002_alter_domain_unique'),
    ]

    operations = [
        migrations.CreateModel(
            name='Collection',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('slug', models.SlugField(verbose_name='Slug')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('page_title', models.CharField(blank=True, max_length=255, verbose_name='Page title')),
                ('meta_description', models.TextField(blank=True, verbose_name='Meta description')),
                ('url_filter_rules', models.TextField(blank=True, default='', help_text='Use separate lines for different rules. See documentation for details.', verbose_name='URL filter rules')),
                ('published', models.BooleanField(default=True, verbose_name='Published')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
                ('lft', models.PositiveIntegerField(db_index=True, editable=False)),
                ('rght', models.PositiveIntegerField(db_index=True, editable=False)),
                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
                ('level', models.PositiveIntegerField(db_index=True, editable=False)),
                ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='pcart_catalog.Collection', verbose_name='Parent')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='collections', to='sites.Site', verbose_name='Site')),
            ],
            options={
                'verbose_name': 'Collection',
                'verbose_name_plural': 'Collections',
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('slug', models.SlugField(max_length=255, verbose_name='Slug')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('page_title', models.CharField(blank=True, max_length=255, verbose_name='Page title')),
                ('meta_description', models.TextField(blank=True, verbose_name='Meta description')),
                ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=30), blank=True, default=list, size=None, verbose_name='Tags')),
                ('properties', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, verbose_name='Properties')),
                ('sku', models.CharField(blank=True, max_length=100, verbose_name='SKU (Stock Keeping Unit)')),
                ('barcode', models.CharField(blank=True, max_length=100, verbose_name='Barcode (ISBN, UPC, GTIN, etc.)')),
                ('price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, verbose_name='Price')),
                ('compare_at_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, verbose_name='Compare at price')),
                ('max_variant_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, verbose_name='Max variant price')),
                ('min_variant_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, verbose_name='Min variant price')),
                ('variants_count', models.PositiveIntegerField(default=0, verbose_name='Variants count')),
                ('weight', models.FloatField(default=0.0, help_text='Used to calculate shipping rates at checkout.', verbose_name='Weight (kg)')),
                ('published', models.BooleanField(default=True, verbose_name='Published')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
                ('collections', models.ManyToManyField(blank=True, help_text="Add this product to a collection so it's easy to find in your store.", related_name='products', to='pcart_catalog.Collection', verbose_name='Collections')),
            ],
            options={
                'verbose_name': 'Product',
                'verbose_name_plural': 'Products',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='ProductImage',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(blank=True, default='', max_length=255, verbose_name='Title')),
                ('image', models.ImageField(blank=True, null=True, upload_to=pcart_catalog.models.generate_product_image_filename, verbose_name='Image')),
                ('html_snippet', models.TextField(blank=True, default='', verbose_name='HTML snippet')),
                ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=30), blank=True, default=list, size=None, verbose_name='Tags')),
                ('position', models.PositiveIntegerField(default=0, verbose_name='Position')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='pcart_catalog.Product', verbose_name='Product')),
            ],
            options={
                'verbose_name': 'Product image',
                'verbose_name_plural': 'Product images',
            },
        ),
        migrations.CreateModel(
            name='ProductStatus',
            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')),
                ('show_buy_button', models.BooleanField(default=True, verbose_name='Show buy button')),
                ('is_visible', models.BooleanField(default=True, verbose_name='Is visible')),
                ('is_searchable', models.BooleanField(default=True, verbose_name='Is searchable')),
                ('weight', models.PositiveIntegerField(default=0, verbose_name='Weight')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
            ],
            options={
                'verbose_name': 'Product status',
                'verbose_name_plural': 'Product statuses',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='ProductType',
            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')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
            ],
            options={
                'verbose_name': 'Product type',
                'verbose_name_plural': 'Product types',
                'ordering': ['title', 'id'],
            },
        ),
        migrations.CreateModel(
            name='ProductTypeProperty',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('default_value', models.CharField(blank=True, max_length=255, verbose_name='Default value')),
                ('tag_prefix', models.CharField(blank=True, max_length=10, verbose_name='Tag prefix')),
                ('use_in_filters', models.BooleanField(default=False, verbose_name='Use in filters')),
                ('for_variants', models.BooleanField(default=False, verbose_name='For variants')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
                ('product_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='properties', to='pcart_catalog.ProductType', verbose_name='Product type')),
            ],
            options={
                'verbose_name': 'Product type property',
                'verbose_name_plural': 'Product type properties',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='ProductVariant',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('slug', models.SlugField(max_length=255, verbose_name='Slug')),
                ('tags', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=30), blank=True, default=list, size=None, verbose_name='Tags')),
                ('properties', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, verbose_name='Properties')),
                ('sku', models.CharField(blank=True, max_length=100, verbose_name='SKU (Stock Keeping Unit)')),
                ('barcode', models.CharField(blank=True, max_length=100, verbose_name='Barcode (ISBN, UPC, GTIN, etc.)')),
                ('price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, verbose_name='Price')),
                ('added', models.DateTimeField(auto_now_add=True, verbose_name='Added')),
                ('changed', models.DateTimeField(auto_now=True, verbose_name='Changed')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='pcart_catalog.Product', verbose_name='Product')),
                ('status', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='pcart_catalog.ProductStatus', verbose_name='Status')),
            ],
            options={
                'verbose_name': 'Product variant',
                'verbose_name_plural': 'Product variants',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='Vendor',
            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')),
            ],
            options={
                'verbose_name': 'Vendor',
                'verbose_name_plural': 'Vendors',
                'ordering': ['title'],
            },
        ),
        migrations.AddField(
            model_name='product',
            name='product_type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='products', to='pcart_catalog.ProductType', verbose_name='Product type'),
        ),
        migrations.AddField(
            model_name='product',
            name='status',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='products', to='pcart_catalog.ProductStatus', verbose_name='Status'),
        ),
        migrations.AddField(
            model_name='product',
            name='vendor',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='products', to='pcart_catalog.Vendor', verbose_name='Vendor'),
        ),
        migrations.AlterUniqueTogether(
            name='productvariant',
            unique_together=set([('product', 'slug')]),
        ),
    ]
