# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-09-12 19:47
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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Answer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('annotation', models.TextField(blank=True)),
                ('text', models.TextField(blank=True)),
                ('display_text', models.TextField(blank=True)),
            ],
            options={
                'verbose_name_plural': 'Answers',
                'verbose_name': 'Answer',
            },
        ),
        migrations.CreateModel(
            name='Observation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('context', models.TextField()),
                ('aproved', models.BooleanField(default=False)),
                ('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Answer')),
            ],
            options={
                'verbose_name_plural': 'Observations',
                'verbose_name': 'Observation',
            },
        ),
        migrations.CreateModel(
            name='Project',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=500)),
                ('object_id', models.PositiveIntegerField()),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'verbose_name_plural': 'Projects',
                'verbose_name': 'Project',
            },
        ),
        migrations.CreateModel(
            name='Question',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('class_to_load', models.CharField(max_length=30)),
                ('text', models.TextField()),
                ('help', models.TextField(blank=True)),
                ('answer_options', django.contrib.postgres.fields.jsonb.JSONField()),
                ('required', models.IntegerField(choices=[(0, 'Optional'), (1, 'Required'), (2, 'Required by hierarchy')], default=0)),
                ('order', models.CharField(blank=True, max_length=10)),
                ('auto', models.BooleanField(default=False)),
            ],
            options={
                'verbose_name_plural': 'Questions',
                'verbose_name': 'Question',
            },
        ),
        migrations.CreateModel(
            name='Report',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('template', django.contrib.postgres.fields.jsonb.JSONField(default=[{'human_name': 'General information', 'name': 'categ0', 'order': 0, 'subcategories': [{'human_name': 'General information', 'name': 'categ0_categ0', 'order': 0, 'question': [], 'questions': []}], 'subcategories_count': 1}])),
                ('questions', django.contrib.postgres.fields.jsonb.JSONField(default={})),
                ('opening_date', models.DateField()),
            ],
            options={
                'verbose_name_plural': 'Reports',
                'verbose_name': 'Report',
            },
        ),
        migrations.CreateModel(
            name='ReportByProject',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField(verbose_name='Opening date')),
                ('submit_date', models.DateField(verbose_name='Submit date')),
                ('state', models.SmallIntegerField(choices=[(0, 'Submit pending'), (1, 'Unsubmitted'), (2, 'Aproved'), (3, 'Editing'), (4, 'Canceled'), (5, 'Rejected'), (6, 'In review')], default=0)),
                ('actions', models.TextField(blank=True, null=True)),
                ('review_percentage', models.SmallIntegerField(default=0)),
                ('complete', models.BooleanField(default=False)),
                ('make_another', models.BooleanField(default=False)),
                ('created_automatically', models.BooleanField(default=False)),
                ('creation_date', models.DateField(auto_now=True)),
                ('additional_info', models.TextField(blank=True, null=True)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Project')),
                ('report', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Report')),
            ],
            options={
                'verbose_name_plural': 'Reports by project',
                'verbose_name': 'Report by project',
            },
        ),
        migrations.CreateModel(
            name='ReportType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.TextField()),
                ('app_name', models.SlugField()),
                ('name', models.SlugField()),
                ('action_ok', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='action_ok', to='async_notifications.EmailTemplate')),
                ('report_end', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='report_end', to='async_notifications.EmailTemplate')),
                ('report_start', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='report_start', to='async_notifications.EmailTemplate')),
                ('responsable_change', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='responsable_change', to='async_notifications.EmailTemplate')),
                ('revision_turn', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='revision_turn', to='async_notifications.EmailTemplate')),
            ],
            options={
                'verbose_name_plural': 'Report types',
                'verbose_name': 'Report type',
            },
        ),
        migrations.CreateModel(
            name='Reviewer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.SmallIntegerField(choices=[(1, 'First'), (2, 'Second'), (3, 'Third'), (4, 'Fourth'), (5, 'Fifth'), (6, 'Sixth'), (7, 'Seventh')])),
                ('state', models.SmallIntegerField(choices=[(0, 'Unsupported'), (1, 'Supported'), (2, 'In review'), (3, 'Supported by the system'), (4, 'Unsupported by the system')], default=0)),
                ('active', models.BooleanField(default=True)),
                ('make_observations', models.BooleanField(default=False)),
                ('can_ask', models.BooleanField(default=False)),
                ('can_review', models.BooleanField(default=False)),
                ('assigned_automatically', models.BooleanField(default=False)),
                ('report', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.ReportByProject')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'Reviewers',
                'verbose_name': 'Reviewer',
            },
        ),
        migrations.CreateModel(
            name='RevisionTree',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('assignment_criteria', models.CharField(max_length=100)),
                ('description', models.TextField()),
                ('report_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.ReportType')),
            ],
            options={
                'verbose_name_plural': 'Revision Tree',
                'verbose_name': 'Revision Tree',
            },
        ),
        migrations.CreateModel(
            name='RevisionTreeUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.SmallIntegerField(choices=[(1, 'First'), (2, 'Second'), (3, 'Third'), (4, 'Fourth'), (5, 'Fifth'), (6, 'Sixth'), (7, 'Seventh')])),
                ('make_observations', models.BooleanField(default=True)),
                ('can_ask', models.BooleanField(default=True)),
                ('can_review', models.BooleanField(default=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'Revision Tree Users',
                'verbose_name': 'Revision Tree User',
            },
        ),
        migrations.AddField(
            model_name='revisiontree',
            name='revision_tree_user',
            field=models.ManyToManyField(to='report_builder.RevisionTreeUser'),
        ),
        migrations.AddField(
            model_name='report',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.ReportType'),
        ),
        migrations.AddField(
            model_name='question',
            name='report',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Report'),
        ),
        migrations.AddField(
            model_name='observation',
            name='reviewer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Reviewer'),
        ),
        migrations.AddField(
            model_name='answer',
            name='question',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.Question'),
        ),
        migrations.AddField(
            model_name='answer',
            name='report',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='report_builder.ReportByProject'),
        ),
        migrations.AddField(
            model_name='answer',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
    ]