# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2017-03-22 14:42
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('products', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='AttributeOption',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('option', models.CharField(max_length=255, verbose_name='Option')),
                ('option_uk', models.CharField(max_length=255, null=True, verbose_name='Option')),
            ],
            options={
                'verbose_name': 'Attribute option',
                'verbose_name_plural': 'Attribute options',
            },
        ),
        migrations.CreateModel(
            name='AttributeOptionGroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128, verbose_name='Name')),
            ],
            options={
                'verbose_name': 'Attribute option group',
                'verbose_name_plural': 'Attribute option groups',
            },
        ),
        migrations.CreateModel(
            name='ProductAttribute',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128, verbose_name='Name')),
                ('name_uk', models.CharField(max_length=128, null=True, verbose_name='Name')),
                ('slug', models.CharField(blank=True, db_index=True, max_length=255, verbose_name='Code')),
                ('type', models.PositiveSmallIntegerField(choices=[(1, 'Text'), (2, 'Integer'), (3, 'True / False'), (5, 'Option')], default=1, verbose_name='Type')),
                ('required', models.BooleanField(default=False, verbose_name='Required')),
                ('is_filter', models.BooleanField(default=False, verbose_name='Is filter')),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attributes', to='products.ProductCategory', verbose_name='Product category')),
                ('option_group', models.OneToOneField(blank=True, help_text='Select an option group if using type "Option"', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attribute', to='attributes.AttributeOptionGroup', verbose_name='Option Group')),
            ],
            options={
                'ordering': ['slug'],
                'verbose_name': 'Product attribute',
                'verbose_name_plural': 'Product attributes',
            },
        ),
        migrations.CreateModel(
            name='ProductAttributeValue',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value_text', models.TextField(blank=True, null=True, verbose_name='Text')),
                ('value_int', models.IntegerField(blank=True, null=True, verbose_name='Integer')),
                ('value_bool', models.NullBooleanField(verbose_name='Boolean')),
                ('attribute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='values', to='attributes.ProductAttribute', verbose_name='Attribute')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attribute_values', to='products.Product', verbose_name='Product')),
                ('value_option', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='attributes.AttributeOption', verbose_name='Value option')),
            ],
            options={
                'ordering': ('attribute__name',),
                'verbose_name': 'Product attribute value',
                'verbose_name_plural': 'Product attribute values',
            },
        ),
        migrations.AddField(
            model_name='attributeoption',
            name='group',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='attributes.AttributeOptionGroup', verbose_name='Group'),
        ),
        migrations.AlterUniqueTogether(
            name='productattributevalue',
            unique_together=set([('attribute', 'product')]),
        ),
        migrations.AlterUniqueTogether(
            name='attributeoption',
            unique_together=set([('group', 'option')]),
        ),
    ]
