# Generated by Django 3.1.2 on 2020-10-23 15:24

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("people", "0001_creer_modeles"),
        ("groups", "0001_creer_modeles"),
        ("events", "0001_creer_modeles"),
    ]

    operations = [
        migrations.CreateModel(
            name="Activity",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="date de création",
                    ),
                ),
                (
                    "modified",
                    models.DateTimeField(
                        auto_now=True, verbose_name="dernière modification"
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(
                        default=django.utils.timezone.now,
                        verbose_name="Date de la notification",
                    ),
                ),
                ("type", models.CharField(max_length=50, verbose_name="Type")),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("U", "Non affichée"),
                            ("S", "Affichée"),
                            ("I", "Interagie"),
                        ],
                        default="U",
                        max_length=1,
                        verbose_name="Status",
                    ),
                ),
                (
                    "meta",
                    models.JSONField(
                        blank=True, default=dict, verbose_name="Autres données"
                    ),
                ),
                (
                    "event",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notifications",
                        related_query_name="notification",
                        to="events.event",
                    ),
                ),
                (
                    "recipient",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="received_notifications",
                        related_query_name="received_notification",
                        to="people.person",
                    ),
                ),
                (
                    "individual",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="people.person",
                    ),
                ),
                (
                    "supportgroup",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notifications",
                        related_query_name="notification",
                        to="groups.supportgroup",
                    ),
                ),
            ],
            options={
                "ordering": ("-created",),
            },
        ),
        migrations.AddIndex(
            model_name="activity",
            index=models.Index(
                fields=["recipient", "created"], name="notifications_by_recipient"
            ),
        ),
    ]
