# Generated by Django 3.0.5 on 2020-05-30 17:05
# pylint: disable=invalid-name,missing-module-docstring,missing-class-docstring
import django.contrib.postgres.fields.jsonb
import django.core.serializers.json
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="ModelReview",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "review_status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("1", "Approved"),
                            ("3", "Pending"),
                            ("2", "Rejected"),
                        ],
                        db_index=True,
                        default="3",
                        max_length=1,
                        verbose_name="Review Status",
                    ),
                ),
                (
                    "review_date",
                    models.DateTimeField(
                        blank=True, default=None, null=True, verbose_name="Review Date"
                    ),
                ),
                (
                    "object_id",
                    models.PositiveIntegerField(
                        db_index=True, verbose_name="Object ID"
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "modified",
                    models.DateTimeField(auto_now=True, verbose_name="Modified"),
                ),
                (
                    "data",
                    django.contrib.postgres.fields.jsonb.JSONField(
                        default=dict,
                        encoder=django.core.serializers.json.DjangoJSONEncoder,
                        verbose_name="Data",
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.ContentType",
                        verbose_name="Content Type",
                    ),
                ),
            ],
            options={
                "verbose_name": "Model Review",
                "verbose_name_plural": "Model Reviews",
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Reviewer",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "review_status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("1", "Approved"),
                            ("3", "Pending"),
                            ("2", "Rejected"),
                        ],
                        db_index=True,
                        default="3",
                        max_length=1,
                        verbose_name="Review Status",
                    ),
                ),
                (
                    "review_date",
                    models.DateTimeField(
                        blank=True, default=None, null=True, verbose_name="Review Date"
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "modified",
                    models.DateTimeField(auto_now=True, verbose_name="Modified"),
                ),
                (
                    "level",
                    models.IntegerField(
                        blank=True,
                        db_index=True,
                        default=0,
                        # pylint: disable=line-too-long
                        help_text="Used to control when a reviewer is asked for their review. For example, a level 2 reviewer may have to wait until all level 1 reviews are done.",  # noqa
                        verbose_name="Level",
                    ),
                ),
                (
                    "reviewed",
                    models.BooleanField(
                        blank=True,
                        db_index=True,
                        default=False,
                        verbose_name="Reviewed",
                    ),
                ),
                (
                    "review",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="model_reviews.ModelReview",
                        verbose_name="Model Review",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={"verbose_name": "Reviewer", "verbose_name_plural": "Reviewers"},
        ),
        migrations.AddField(
            model_name="modelreview",
            name="reviewers",
            field=models.ManyToManyField(
                related_name="modelreview_reviewers",
                through="model_reviews.Reviewer",
                to=settings.AUTH_USER_MODEL,
                verbose_name="Reviewer(s)",
            ),
        ),
        migrations.AddField(
            model_name="modelreview",
            name="user",
            field=models.ForeignKey(
                blank=True,
                default=None,
                help_text="The user who submitted the request for review",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="modelreview_user",
                to=settings.AUTH_USER_MODEL,
                verbose_name="User",
            ),
        ),
        migrations.AddIndex(
            model_name="modelreview",
            index=models.Index(
                fields=["content_type", "object_id"],
                name="model_revie_content_484062_idx",
            ),
        ),
    ]
