# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2018-06-26 11:21
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
import waldur_core.core.fields
import django_fsm


class Migration(migrations.Migration):

    dependencies = [
        ('structure', '0001_squashed_0054'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('marketplace', '0010_immutable_default_json'),
    ]

    operations = [
        migrations.CreateModel(
            name='Item',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('uuid', waldur_core.core.fields.UUIDField()),
                ('attributes', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict)),
                ('offering', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='marketplace.Offering')),
                ('cost', models.DecimalField(blank=True, decimal_places=10, max_digits=22, null=True)),
            ],
            options={
                'verbose_name': 'Order item',
            },
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('uuid', waldur_core.core.fields.UUIDField()),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='structure.Project')),
                ('state', django_fsm.FSMIntegerField(choices=[(1, 'draft'), (2, 'requested for approval'), (3, 'executing'), (4, 'done'), (5, 'terminated')], default=1)),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders',
                                                  to=settings.AUTH_USER_MODEL)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('approved_at', models.DateTimeField(blank=True, editable=False, null=True)),
                ('total_cost', models.DecimalField(blank=True, decimal_places=10, max_digits=22, null=True)),
            ],
            options={
                'verbose_name': 'Order',
            },
        ),
        migrations.AddField(
            model_name='item',
            name='order',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='marketplace.Order'),
        ),
        migrations.AlterModelOptions(
            name='item',
            options={'ordering': ('created',), 'verbose_name': 'Order item'},
        ),
        migrations.AlterModelOptions(
            name='order',
            options={'ordering': ('created',), 'verbose_name': 'Order'},
        ),
    ]
