# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-29 07:45
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields


class Migration(migrations.Migration):

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

    operations = [
        migrations.CreateModel(
            name='BusinessProcess',
            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')),
                ('title', models.CharField(max_length=30)),
                ('short_title', models.CharField(max_length=10)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Employee',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(max_length=30)),
                ('last_name', models.CharField(max_length=30)),
                ('patronymic', models.CharField(max_length=30)),
                ('is_head', models.BooleanField()),
            ],
        ),
        migrations.CreateModel(
            name='Plan',
            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')),
                ('work_type', models.PositiveSmallIntegerField(choices=[(0, 'For order'), (1, 'For project'), (2, 'For business process'), (3, 'For minutes of the meeting'), (4, 'Arbitrary')])),
                ('title', models.CharField(max_length=100)),
                ('status', models.PositiveSmallIntegerField(choices=[(0, 'Prepared'), (1, 'On agreement'), (2, 'Agreed')])),
                ('commentary', models.CharField(max_length=100)),
                ('creation_date', models.DateTimeField(verbose_name='Creation data')),
                ('business_process', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.BusinessProcess')),
                ('created_by_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Employee')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Project',
            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')),
                ('code', models.CharField(max_length=15, unique=True)),
                ('title', models.CharField(max_length=100, unique=True)),
                ('openning_order_number', models.CharField(max_length=20)),
                ('openning_order_date', models.DateField(verbose_name='openning order date')),
                ('closure_act_number', models.CharField(max_length=20)),
                ('closure_act_date', models.DateField(verbose_name='closure act date')),
                ('completion_date', models.DateField(verbose_name='completion date')),
                ('exec', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Employee')),
                ('manager', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Employee')),
                ('workflow', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.BusinessProcess')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Task',
            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')),
                ('text', models.CharField(max_length=50)),
                ('idx', models.PositiveIntegerField()),
                ('labor_input_planned', models.PositiveIntegerField()),
                ('duration_planned', models.FloatField()),
                ('begin_planned', models.DateField(verbose_name='Planned start')),
                ('end_planned', models.DateField(verbose_name='Planned finish')),
                ('status', models.PositiveSmallIntegerField(choices=[(0, 'Prepared'), (1, 'On agreement'), (2, 'Stopped'), (3, 'In progress'), (4, 'Finished')])),
                ('completeness', models.PositiveSmallIntegerField()),
                ('prio', models.PositiveSmallIntegerField(default=0)),
                ('labor_input_actual', models.PositiveIntegerField()),
                ('duration_actual', models.FloatField()),
                ('begin_actual', models.DateTimeField(verbose_name='Actual start date')),
                ('end_actual', models.DateTimeField(verbose_name='Actual finish date')),
                ('exec', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Employee')),
                ('parent_task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Task')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Plan')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.RemoveField(
            model_name='worker',
            name='post',
        ),
        migrations.RenameField(
            model_name='post',
            old_name='name',
            new_name='title',
        ),
        migrations.AddField(
            model_name='structureunit',
            name='created',
            field=model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
        ),
        migrations.AddField(
            model_name='structureunit',
            name='modified',
            field=model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified'),
        ),
        migrations.AlterField(
            model_name='structureunit',
            name='head',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Employee'),
        ),
        migrations.AlterField(
            model_name='structureunit',
            name='parent',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.StructureUnit'),
        ),
        migrations.AlterField(
            model_name='structureunit',
            name='type',
            field=models.PositiveSmallIntegerField(choices=[(0, 'Department'), (1, 'Section'), (2, 'Team')]),
        ),
        migrations.DeleteModel(
            name='Worker',
        ),
        migrations.AddField(
            model_name='plan',
            name='project',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.Project'),
        ),
        migrations.AddField(
            model_name='employee',
            name='branch',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.StructureUnit'),
        ),
        migrations.AddField(
            model_name='employee',
            name='default_deputy',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Employee'),
        ),
        migrations.AddField(
            model_name='employee',
            name='deputy_by_order',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Employee'),
        ),
        migrations.AddField(
            model_name='employee',
            name='post',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Post'),
        ),
        migrations.AddField(
            model_name='businessprocess',
            name='exec',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Employee'),
        ),
        migrations.AddField(
            model_name='businessprocess',
            name='manager',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='app.Employee'),
        ),
    ]
