# Generated by Django 3.1.2 on 2020-11-19 11:34

import uuid

import django.db.models.deletion
import simple_history.models
from django.conf import settings
from django.db import migrations, models

import api.barriers.mixins


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("barriers", "0097_auto_20201113_1149"),
        ("assessment", "0013_rename_assessment"),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="economicassessment",
            options={
                "ordering": ("-created_on",),
                "permissions": (
                    ("archive_economicassessment", "Can archive economic assessment"),
                    ("approve_economicassessment", "Can approve economic assessment"),
                ),
            },
        ),
        migrations.RenameField(
            model_name="economicassessment",
            old_name="impact",
            new_name="rating",
        ),
        migrations.RenameField(
            model_name="historicaleconomicassessment",
            old_name="impact",
            new_name="rating",
        ),
        migrations.RemoveField(
            model_name="economicassessment",
            name="is_active",
        ),
        migrations.RemoveField(
            model_name="historicaleconomicassessment",
            name="is_active",
        ),
        migrations.AddField(
            model_name="economicassessment",
            name="analysis_data",
            field=models.TextField(blank=True),
        ),
        migrations.AddField(
            model_name="economicassessment",
            name="approved",
            field=models.BooleanField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="economicassessment",
            name="ready_for_approval",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="economicassessment",
            name="reviewed_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="economicassessment",
            name="reviewed_on",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="historicaleconomicassessment",
            name="analysis_data",
            field=models.TextField(blank=True),
        ),
        migrations.AddField(
            model_name="historicaleconomicassessment",
            name="approved",
            field=models.BooleanField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="historicaleconomicassessment",
            name="ready_for_approval",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="historicaleconomicassessment",
            name="reviewed_by",
            field=models.ForeignKey(
                blank=True,
                db_constraint=False,
                null=True,
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="historicaleconomicassessment",
            name="reviewed_on",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name="economicassessment",
            name="barrier",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="economic_assessments",
                to="barriers.barrier",
            ),
        ),
        migrations.CreateModel(
            name="HistoricalEconomicImpactAssessment",
            fields=[
                (
                    "created_on",
                    models.DateTimeField(
                        blank=True, db_index=True, editable=False, null=True
                    ),
                ),
                (
                    "modified_on",
                    models.DateTimeField(blank=True, editable=False, null=True),
                ),
                ("archived", models.BooleanField(default=False)),
                ("archived_on", models.DateTimeField(blank=True, null=True)),
                ("archived_reason", models.TextField(blank=True)),
                ("id", models.UUIDField(db_index=True, default=uuid.uuid4)),
                (
                    "impact",
                    models.PositiveIntegerField(
                        choices=[
                            (1, "1: £ less than a thousand"),
                            (2, "2: £ tens of thousands"),
                            (3, "3: £ hundreds of thousands"),
                            (4, "4: £ millions"),
                            (5, "5: £ tens of millions"),
                            (6, "6: £ hundreds of millions"),
                            (7, "7: £ billions"),
                            (8, "8: £ tens of billions"),
                        ]
                    ),
                ),
                ("explanation", models.TextField(blank=True)),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "archived_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "economic_assessment",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="assessment.economicassessment",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "modified_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical economic impact assessment",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="EconomicImpactAssessment",
            fields=[
                (
                    "created_on",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                ("modified_on", models.DateTimeField(auto_now=True, null=True)),
                ("archived", models.BooleanField(default=False)),
                ("archived_on", models.DateTimeField(blank=True, null=True)),
                ("archived_reason", models.TextField(blank=True)),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                (
                    "impact",
                    models.PositiveIntegerField(
                        choices=[
                            (1, "1: £ less than a thousand"),
                            (2, "2: £ tens of thousands"),
                            (3, "3: £ hundreds of thousands"),
                            (4, "4: £ millions"),
                            (5, "5: £ tens of millions"),
                            (6, "6: £ hundreds of millions"),
                            (7, "7: £ billions"),
                            (8, "8: £ tens of billions"),
                        ]
                    ),
                ),
                ("explanation", models.TextField(blank=True)),
                (
                    "archived_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "economic_assessment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="economic_impact_assessments",
                        to="assessment.economicassessment",
                    ),
                ),
                (
                    "modified_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("-created_on",),
                "permissions": (
                    (
                        "archive_economicimpactassessment",
                        "Can archive economic impact assessment",
                    ),
                ),
            },
            bases=(api.barriers.mixins.BarrierRelatedMixin, models.Model),
        ),
    ]
