# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-14 11:01
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import userdata.models.address
import userdata.models.profile
import userdata.models.profile_business
from django.core import serializers
import django.db.models.deletion
from django.conf import settings

import os


def load_data(apps, schema_editor):
    user_model = apps.get_model('auth', 'User')
    with open(os.path.join(settings.BASE_DIR, 'userdata', 'fixtures', 'users.json'), 'rb') as data:
        users = serializers.deserialize('json', data)
        user_model.objects.bulk_create((user.object for user in users))


def unload_data(apps, schema_editor):
    apps.get_model('auth', 'User').objects.all().delete()


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('core', '0002_countrynumberphone_country'),
    ]

    operations = [
        migrations.CreateModel(
            name='AboutBusiness',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('num', models.PositiveIntegerField()),
                ('title', models.CharField(blank=True, max_length=256, null=True)),
                ('text', models.TextField(blank=True, null=True)),
                ('img_1', models.ImageField(blank=True, null=True, upload_to='')),
                ('img_2', models.ImageField(blank=True, null=True, upload_to='')),
                ('img_3', models.ImageField(blank=True, null=True, upload_to='')),
                ('video', models.TextField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='AddressDeliveryBusiness',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('name', models.CharField(default='Address name', max_length=256)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AddressDeliveryDocs',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('name', models.CharField(default='Address name', max_length=256)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AddressDeliveryProfile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('name', models.CharField(default='Address name', max_length=256)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AddressLegal',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('name', models.CharField(default='Address name', max_length=256)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AddressPayment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('name', models.CharField(default='Address name', max_length=256)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AddressPickUp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(default=0)),
                ('address', models.CharField(default='Default address', max_length=256)),
                ('postal_code', models.CharField(default='000000', max_length=10)),
                ('default', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('name', models.CharField(blank=True, max_length=100, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('content_type', models.ForeignKey(default=userdata.models.address.get_city_default_id, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ClassProductForProfile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.SmallIntegerField(choices=[(1, 'Halal'), (2, 'Kosher'), (3, 'Vegetarian'), (4, 'Vegan'), (5, 'BIO'), (6, 'Lactose Free'), (7, 'Gluten Free'), (8, 'Allergen Free')])),
            ],
        ),
        migrations.CreateModel(
            name='Confirmation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=50)),
                ('e_mail', models.EmailField(max_length=254)),
                ('conf', models.BooleanField(default=False)),
                ('email', models.BooleanField(default=False)),
                ('phone', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='FileForProfile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type_profile', models.PositiveSmallIntegerField(choices=[(1, 'personal'), (2, 'business')], default=1)),
                ('for_confirmation', models.BooleanField(default=False)),
                ('img', models.ImageField(upload_to='')),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Profile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('middle_name', models.CharField(blank=True, max_length=30, null=True)),
                ('gender', models.PositiveSmallIntegerField(choices=[(1, 'not set'), (2, 'male'), (3, 'female')], default=1)),
                ('birthday', models.DateField(blank=True, null=True)),
                ('avatar', models.ImageField(blank=True, null=True, upload_to=userdata.models.profile.pp_directory_path)),
                ('number_phone', models.BigIntegerField(blank=True, null=True)),
                ('tax_number', models.CharField(blank=True, max_length=256, null=True)),
                ('confirmed_email', models.BooleanField(default=False)),
                ('confirmed_phone', models.BooleanField(default=False)),
                ('about_me', models.TextField(blank=True, null=True)),
                ('about_me_eng', models.TextField(blank=True, null=True)),
                ('confirmed_profile', models.BooleanField(default=False)),
                ('password_updated', models.DateTimeField(null=True)),
                ('personal_offers_email', models.BooleanField(default=False)),
                ('newsletter_email', models.BooleanField(default=False)),
                ('addition_receiver', models.TextField(blank=True, max_length=100, null=True)),
                ('receiver_phonenumber', models.BigIntegerField(blank=True, null=True)),
                ('code_num_phone', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.CountryNumberphone')),
                ('language', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='core.Language')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ProfileBusiness',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('terms_of_use', models.BooleanField(default=False)),
                ('type_of_business', models.PositiveSmallIntegerField(choices=[(1, 'farmer'), (2, 'recycler')], default=1)),
                ('organization_type', models.PositiveSmallIntegerField(choices=[(1, 'self-employed'), (2, 'Limited Liablility Company (LLC or LTD)'), (3, 'Open Joint Stock Company (OJSC)'), (4, 'Close Joint Stock Company (CJSC)')], default=1)),
                ('organization_name', models.CharField(max_length=256)),
                ('vat', models.CharField(max_length=256)),
                ('registration_number', models.CharField(max_length=256)),
                ('first_name', models.CharField(max_length=50)),
                ('middle_name', models.CharField(blank=True, max_length=50, null=True)),
                ('last_name', models.CharField(max_length=50)),
                ('position_in_com', models.CharField(max_length=50)),
                ('phone_number', models.BigIntegerField(blank=True, null=True)),
                ('email', models.EmailField(max_length=254)),
                ('about_me', models.TextField(blank=True, null=True)),
                ('about_me_eng', models.TextField(blank=True, null=True)),
                ('avatar', models.ImageField(blank=True, null=True, upload_to=userdata.models.profile_business.bp_directory_path)),
                ('confirmed_profile_bus', models.BooleanField(default=False)),
                ('addition_receiver', models.TextField(blank=True, max_length=100, null=True)),
                ('receiver_phonenumber', models.BigIntegerField(blank=True, null=True)),
                ('code_num_phone', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.CountryNumberphone')),
                ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='userdata.Profile')),
            ],
        ),
        migrations.AddField(
            model_name='classproductforprofile',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.Profile'),
        ),
        migrations.AddField(
            model_name='addresspickup',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.ProfileBusiness'),
        ),
        migrations.AddField(
            model_name='addresspayment',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.Profile'),
        ),
        migrations.AddField(
            model_name='addresslegal',
            name='profile',
            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='userdata.ProfileBusiness'),
        ),
        migrations.AddField(
            model_name='addressdeliveryprofile',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.Profile'),
        ),
        migrations.AddField(
            model_name='addressdeliverydocs',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.ProfileBusiness'),
        ),
        migrations.AddField(
            model_name='addressdeliverybusiness',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.ProfileBusiness'),
        ),
        migrations.AddField(
            model_name='aboutbusiness',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userdata.ProfileBusiness'),
        ),
        migrations.AlterUniqueTogether(
            name='classproductforprofile',
            unique_together=set([('name', 'profile')]),
        ),
        migrations.AlterUniqueTogether(
            name='aboutbusiness',
            unique_together=set([('profile', 'num')]),
        ),
        migrations.RunPython(
            load_data,
            reverse_code=unload_data
        ),

    ]
