# Generated by Django 3.2.16 on 2023-05-05 15:31

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import picklefield.fields
import uuid


class Migration(migrations.Migration):
    replaces = [
        ("jasmin_notifications", "0001_initial"),
        ("jasmin_notifications", "0002_auto_20210524_1418"),
        ("jasmin_notifications", "0003_auto_20220207_1359"),
        ("jasmin_notifications", "0004_alter_notificationtype_level"),
    ]

    initial = True

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

    operations = [
        migrations.CreateModel(
            name="NotificationType",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "name",
                    models.CharField(
                        help_text="A short name for the notification",
                        max_length=50,
                        validators=[
                            django.core.validators.RegexValidator(regex="^[a-zA-Z0-9_-]+$")
                        ],
                    ),
                ),
                (
                    "level",
                    models.CharField(
                        choices=[
                            ("info", "Info"),
                            ("attention", "Attention"),
                            ("success", "Success"),
                            ("warning", "Warning"),
                            ("error", "Error"),
                        ],
                        max_length=9,
                    ),
                ),
                (
                    "display",
                    models.BooleanField(
                        default=True,
                        help_text="Indicates of notifications of this type should be displayed on site as well as emailed (user notifications only)",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Notification",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                ("uuid", models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ("target_id", models.CharField(max_length=250)),
                ("link", models.URLField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("followed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "extra_context",
                    picklefield.fields.PickledObjectField(default=dict, editable=False),
                ),
                (
                    "notification_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="jasmin_notifications.notificationtype",
                    ),
                ),
                (
                    "polymorphic_ctype",
                    models.ForeignKey(
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="polymorphic_jasmin_notifications.notification_set+",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "target_ctype",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype"
                    ),
                ),
            ],
            options={
                "get_latest_by": "created_at",
            },
        ),
        migrations.CreateModel(
            name="EmailNotification",
            fields=[
                (
                    "notification_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="jasmin_notifications.notification",
                    ),
                ),
                ("email", models.EmailField(max_length=254)),
            ],
            options={
                "abstract": False,
                "base_manager_name": "objects",
            },
            bases=("jasmin_notifications.notification",),
            managers=[
                ("objects", django.db.models.manager.Manager()),
                ("base_objects", django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name="UserNotification",
            fields=[
                (
                    "notification_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="jasmin_notifications.notification",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
                    ),
                ),
            ],
            options={
                "abstract": False,
                "base_manager_name": "objects",
            },
            bases=("jasmin_notifications.notification",),
            managers=[
                ("objects", django.db.models.manager.Manager()),
                ("base_objects", django.db.models.manager.Manager()),
            ],
        ),
        migrations.AlterModelManagers(
            name="emailnotification",
            managers=[],
        ),
        migrations.AlterModelManagers(
            name="usernotification",
            managers=[],
        ),
        migrations.AddField(
            model_name="emailnotification",
            name="cc",
            field=models.EmailField(blank=True, max_length=254, null=True),
        ),
    ]
