# Generated by Django 4.2.6 on 2023-11-21 08:59

import datetime
import df_notifications.fields
import df_notifications.models
import df_survey.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import hashid_field.field
import model_utils.fields


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("df_notifications", "0008_alter_custompushmessage_action_url_and_more"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Category",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("slug", models.CharField(max_length=128)),
            ],
            options={
                "verbose_name_plural": "Survey categories",
            },
        ),
        migrations.CreateModel(
            name="Question",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("question", models.CharField(max_length=255)),
                (
                    "type",
                    models.CharField(
                        choices=[
                            ("text", "Text"),
                            ("integer", "Integer"),
                            ("date", "Date"),
                            ("single", "Single choice"),
                            ("multi", "Multiple choice"),
                        ],
                        max_length=255,
                    ),
                ),
                ("format", models.TextField(blank=True, default="")),
            ],
        ),
        migrations.CreateModel(
            name="Survey",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=128)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "sequence",
                    models.PositiveSmallIntegerField(
                        default=1000, help_text="Display sequence, lower means first"
                    ),
                ),
                (
                    "task",
                    models.JSONField(
                        blank=True,
                        null=True,
                        validators=[df_survey.models.validate_task_json],
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="df_survey.category",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="UserSurveysReminder",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "channel",
                    df_notifications.fields.NoMigrationsChoicesField(max_length=255),
                ),
                ("template_prefix", models.CharField(max_length=255)),
                ("context", models.JSONField(blank=True, default=dict)),
                (
                    "delay",
                    models.DurationField(
                        default=datetime.timedelta(0),
                        help_text="Send the reminder after this period of time",
                    ),
                ),
                (
                    "cooldown",
                    models.DurationField(
                        default=datetime.timedelta(seconds=3600),
                        help_text="Wait so much time before reminding again",
                    ),
                ),
                (
                    "repeat",
                    models.SmallIntegerField(
                        default=1, help_text="Repeat the reminder this many times"
                    ),
                ),
                (
                    "action",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="Python code to execute. You can use `instance` variable to access current model",
                    ),
                ),
                (
                    "history",
                    models.ManyToManyField(
                        blank=True,
                        editable=False,
                        to="df_notifications.notificationhistory",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=(df_notifications.models.GenericBase, models.Model),
        ),
        migrations.CreateModel(
            name="UserSurveyNotification",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "channel",
                    df_notifications.fields.NoMigrationsChoicesField(max_length=255),
                ),
                ("template_prefix", models.CharField(max_length=255)),
                ("context", models.JSONField(blank=True, default=dict)),
                (
                    "history",
                    models.ManyToManyField(
                        blank=True,
                        editable=False,
                        to="df_notifications.notificationhistory",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=(df_notifications.models.GenericBase, models.Model),
        ),
        migrations.CreateModel(
            name="UserSurvey",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        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",
                    ),
                ),
                ("result", models.JSONField(blank=True, null=True)),
                (
                    "survey",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="df_survey.survey",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-modified"],
            },
        ),
        migrations.CreateModel(
            name="SurveyQuestion",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "sequence",
                    models.PositiveSmallIntegerField(
                        default=1000, help_text="Display sequence, lower means first"
                    ),
                ),
                (
                    "question",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="df_survey.question",
                    ),
                ),
                (
                    "survey",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="df_survey.survey",
                    ),
                ),
            ],
            options={
                "ordering": ("sequence",),
                "unique_together": {("survey", "question")},
            },
        ),
        migrations.AddField(
            model_name="survey",
            name="questions",
            field=models.ManyToManyField(
                through="df_survey.SurveyQuestion", to="df_survey.question"
            ),
        ),
        migrations.CreateModel(
            name="Response",
            fields=[
                (
                    "id",
                    hashid_field.field.BigHashidAutoField(
                        alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
                        auto_created=True,
                        min_length=13,
                        prefix="",
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("response", models.TextField()),
                (
                    "question",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="df_survey.question",
                    ),
                ),
                (
                    "usersurvey",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="df_survey.usersurvey",
                    ),
                ),
            ],
        ),
    ]
