# Generated by Django 3.2.8 on 2022-02-15 19:55

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models

import filer.fields.image
import taggit.managers

from .. import conf


class Migration(migrations.Migration):

    initial = True

    dependencies = (
        [
            ("publicbody", "0039_publicbody_alternative_emails"),
            ("auth", "0012_alter_user_first_name_max_length"),
        ]
        + (
            [
                ("foirequest", "0054_alter_foirequest_options"),
            ]
            if conf.GOVPLAN_ENABLE_FOIREQUEST
            else []
        )
        + [
            migrations.swappable_dependency(settings.FILER_IMAGE_MODEL),
            ("organization", "0001_initial"),
            migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ]
    )

    operations = [
        migrations.CreateModel(
            name="CategorizedGovernmentPlan",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
            ],
            options={
                "verbose_name": "Categorized Government Plan",
                "verbose_name_plural": "Categorized Government Plans",
            },
        ),
        migrations.CreateModel(
            name="Government",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("slug", models.SlugField(max_length=255, unique=True)),
                ("public", models.BooleanField(default=False)),
                ("description", models.TextField(blank=True)),
                ("start_date", models.DateField(blank=True, null=True)),
                ("end_date", models.DateField(blank=True, null=True)),
                ("planning_document", models.URLField(blank=True)),
                (
                    "jurisdiction",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="publicbody.jurisdiction",
                    ),
                ),
            ],
            options={
                "verbose_name": "Government",
                "verbose_name_plural": "Governments",
            },
        ),
        migrations.CreateModel(
            name="GovernmentPlan",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=255)),
                ("slug", models.SlugField(max_length=255, unique=True)),
                ("description", models.TextField(blank=True)),
                ("public", models.BooleanField(default=False)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("not_started", "not started"),
                            ("started", "started"),
                            ("partially_implemented", "partially implemented"),
                            ("implemented", "implemented"),
                            ("deferred", "deferred"),
                        ],
                        default="needs_approval",
                        max_length=25,
                    ),
                ),
                (
                    "rating",
                    models.IntegerField(
                        blank=True,
                        choices=[
                            (1, "terrible"),
                            (2, "bad"),
                            (3, "OK"),
                            (4, "good"),
                            (5, "excellent"),
                        ],
                        null=True,
                    ),
                ),
                ("reference", models.CharField(blank=True, max_length=255)),
                (
                    "categories",
                    taggit.managers.TaggableManager(
                        blank=True,
                        help_text="A comma-separated list of tags.",
                        through="froide_govplan.CategorizedGovernmentPlan",
                        to="publicbody.Category",
                        verbose_name="categories",
                    ),
                ),
                (
                    "government",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="froide_govplan.government",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="auth.group",
                    ),
                ),
                (
                    "image",
                    filer.fields.image.FilerImageField(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.FILER_IMAGE_MODEL,
                        verbose_name="image",
                    ),
                ),
                (
                    "responsible_publicbody",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="publicbody.publicbody",
                    ),
                ),
            ],
            options={
                "verbose_name": "Government plan",
                "verbose_name_plural": "Government plans",
                "ordering": ("reference", "title"),
            },
        ),
        migrations.CreateModel(
            name="GovernmentPlanUpdate",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("timestamp", models.DateTimeField(default=django.utils.timezone.now)),
                ("title", models.CharField(blank=True, max_length=1024)),
                ("content", models.TextField(blank=True)),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("not_started", "not started"),
                            ("started", "started"),
                            ("partially_implemented", "partially implemented"),
                            ("implemented", "implemented"),
                            ("deferred", "deferred"),
                        ],
                        default="",
                        max_length=25,
                    ),
                ),
                (
                    "rating",
                    models.IntegerField(
                        blank=True,
                        choices=[
                            (1, "terrible"),
                            (2, "bad"),
                            (3, "OK"),
                            (4, "good"),
                            (5, "excellent"),
                        ],
                        null=True,
                    ),
                ),
                ("public", models.BooleanField(default=False)),
            ]
            + (
                [
                    (
                        "foirequest",
                        models.ForeignKey(
                            blank=True,
                            null=True,
                            on_delete=django.db.models.deletion.SET_NULL,
                            to="foirequest.foirequest",
                        ),
                    )
                ]
                if conf.GOVPLAN_ENABLE_FOIREQUEST
                else []
            )
            + [
                (
                    "organization",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="organization.organization",
                    ),
                ),
                (
                    "plan",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="updates",
                        to="froide_govplan.governmentplan",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Plan update",
                "verbose_name_plural": "Plan updates",
                "ordering": ("-timestamp",),
                "get_latest_by": "timestamp",
            },
        ),
        migrations.AddField(
            model_name="categorizedgovernmentplan",
            name="content_object",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="froide_govplan.governmentplan",
            ),
        ),
        migrations.AddField(
            model_name="categorizedgovernmentplan",
            name="tag",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="categorized_governmentplan",
                to="publicbody.category",
            ),
        ),
    ]
