# Generated by Django 3.2.18 on 2023-04-23 19:49

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

from NEMO.apps.nemo_ce.migration_utils import NEMOMigration


class Migration(NEMOMigration):

    dependencies = [
        ("NEMO", "0045_version_4_5_0"),
        ("nemo_ce", "0002_ce_tool_reservation_required"),
    ]

    operations = [
        migrations.CreateModel(
            name="TrainingRequest",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "creation_time",
                    models.DateTimeField(
                        auto_now_add=True, help_text="The date and time when the request was created."
                    ),
                ),
                ("message", models.TextField(blank=True, help_text="message to the trainer(s)", null=True)),
                (
                    "status",
                    models.IntegerField(
                        choices=[
                            (1, "Sent"),
                            (2, "Reviewed"),
                            (3, "Invited"),
                            (4, "Accepted"),
                            (5, "Declined"),
                            (6, "Expired"),
                            (7, "Withdrawn"),
                            (8, "Fulfilled"),
                            (9, "Cancelled"),
                        ],
                        default=1,
                    ),
                ),
                (
                    "creator",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="training_requests_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-creation_time"],
            },
        ),
        migrations.CreateModel(
            name="TrainingTechnique",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(help_text="The unique name for this item", max_length=200, unique=True)),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="TrainingRequestTime",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("start_time", models.DateTimeField(help_text="The start date and time of the closure")),
                ("end_time", models.DateTimeField(help_text="The end date and time of the closure")),
                (
                    "training_request",
                    models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="NEMO.trainingrequest"),
                ),
            ],
            options={
                "ordering": ["start_time"],
            },
        ),
        migrations.AddField(
            model_name="trainingrequest",
            name="technique",
            field=models.ForeignKey(
                blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="NEMO.trainingtechnique"
            ),
        ),
        migrations.AddField(
            model_name="trainingrequest",
            name="tool",
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="NEMO.tool"),
        ),
        migrations.AddField(
            model_name="trainingrequest",
            name="trainer",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="training_requests_trainer",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="trainingrequest",
            name="user",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="training_requests_user",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.CreateModel(
            name="TrainingEvent",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "creation_time",
                    models.DateTimeField(
                        auto_now_add=True, help_text="The date and time when the training was created."
                    ),
                ),
                ("start", models.DateTimeField()),
                ("end", models.DateTimeField()),
                ("message", models.TextField(blank=True, help_text="The message to the trainee(s)", null=True)),
                ("capacity", models.PositiveIntegerField()),
                ("cancelled", models.BooleanField(default=False)),
                ("cancellation_time", models.DateTimeField(blank=True, null=True)),
                ("cancellation_reason", models.CharField(blank=True, max_length=200, null=True)),
                (
                    "cancelled_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="training_events_cancelled",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "creator",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="training_events_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "technique",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to="NEMO.trainingtechnique"
                    ),
                ),
                ("tool", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="NEMO.tool")),
                (
                    "trainer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="training_events_trainer",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                ("users", models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                "ordering": ["-end"],
            },
        ),
        migrations.CreateModel(
            name="ToolTrainingDetail",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "duration",
                    models.PositiveIntegerField(
                        blank=True, help_text="The training duration for this tool in minutes", null=True
                    ),
                ),
                (
                    "capacity",
                    models.PositiveIntegerField(
                        blank=True, help_text="The maximum number of attendees when training for this tool", null=True
                    ),
                ),
                (
                    "techniques",
                    models.ManyToManyField(
                        blank=True,
                        to="NEMO.TrainingTechnique",
                        help_text="The techniques available for training on this tool",
                    ),
                ),
                ("tool", models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to="NEMO.tool")),
                (
                    "user_availability_allowed",
                    models.BooleanField(
                        default=False,
                        help_text="Check this box to allow users to submit their availability when requesting training",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="TrainingInvitation",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "creation_time",
                    models.DateTimeField(
                        auto_now_add=True, help_text="The date and time when the request was created."
                    ),
                ),
                (
                    "status",
                    models.IntegerField(
                        choices=[
                            (1, "Sent"),
                            (2, "Reviewed"),
                            (3, "Invited"),
                            (4, "Accepted"),
                            (5, "Declined"),
                            (6, "Expired"),
                            (7, "Withdrawn"),
                            (8, "Fulfilled"),
                            (9, "Cancelled"),
                        ],
                        default=1,
                    ),
                ),
                (
                    "creator",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="training_invitations_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "training_event",
                    models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="NEMO.trainingevent"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="training_invitations_user",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-creation_time"],
                "unique_together": {("training_event", "user")},
            },
        ),
        migrations.AlterField(
            model_name="landingpagechoice",
            name="notifications",
            field=models.CharField(
                blank=True,
                choices=[
                    ("news", "News creation and updates - notifies all users"),
                    ("safetyissue", "New safety issues - notifies staff only"),
                    ("buddyrequest", "New buddy request - notifies all users"),
                    (
                        "buddyrequestmessage",
                        "New buddy request reply - notifies request creator and users who have replied",
                    ),
                    ("adjustmentrequest", "New adjustment request - notifies facility managers only"),
                    (
                        "adjustmentrequestmessage",
                        "New adjustment request reply - notifies request creator and users who have replied",
                    ),
                    (
                        "temporaryphysicalaccessrequest",
                        "New access request - notifies other users on request and reviewers",
                    ),
                    ("trainingrequest", "New training request - notifies trainers only"),
                    ("traininginvitation", "New training invitation - notifies invited users"),
                    ("trainingall", "All training notifications"),
                ],
                help_text="Displays a the number of new notifications for the user. For example, if the user has two unread news notifications then the number '2' would appear for the news icon on the landing page.",
                max_length=100,
                null=True,
            ),
        ),
        migrations.AlterField(
            model_name="notification",
            name="notification_type",
            field=models.CharField(
                choices=[
                    ("news", "News creation and updates - notifies all users"),
                    ("safetyissue", "New safety issues - notifies staff only"),
                    ("buddyrequest", "New buddy request - notifies all users"),
                    (
                        "buddyrequestmessage",
                        "New buddy request reply - notifies request creator and users who have replied",
                    ),
                    ("adjustmentrequest", "New adjustment request - notifies facility managers only"),
                    (
                        "adjustmentrequestmessage",
                        "New adjustment request reply - notifies request creator and users who have replied",
                    ),
                    (
                        "temporaryphysicalaccessrequest",
                        "New access request - notifies other users on request and reviewers",
                    ),
                    ("trainingrequest", "New training request - notifies trainers only"),
                    ("traininginvitation", "New training invitation - notifies invited users"),
                    ("trainingall", "All training notifications"),
                ],
                max_length=100,
            ),
        ),
        migrations.CreateModel(
            name="TrainingHistory",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("status", models.CharField(help_text="The new training item status", max_length=200)),
                (
                    "time",
                    models.DateTimeField(
                        auto_now_add=True, help_text="The date and time when the training item status was changed"
                    ),
                ),
                (
                    "details",
                    models.CharField(
                        blank=True, help_text="The details/reason of this change", max_length=200, null=True
                    ),
                ),
                (
                    "training_event",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="NEMO.trainingevent"
                    ),
                ),
                (
                    "training_invitation",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="NEMO.traininginvitation"
                    ),
                ),
                (
                    "training_request",
                    models.ForeignKey(
                        blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="NEMO.trainingrequest"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="The user who changed the training item status",
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Training histories",
                "ordering": ["-time"],
                "get_latest_by": "time",
            },
        ),
        migrations.AddField(
            model_name="userpreferences",
            name="email_send_training_emails",
            field=models.PositiveIntegerField(
                choices=[(1, "Both emails"), (2, "Main email only"), (3, "Alternate email only"), (0, "Off")],
                default=1,
                help_text="Training emails",
            ),
        ),
        migrations.AlterField(
            model_name="emaillog",
            name="category",
            field=models.IntegerField(
                choices=[
                    (0, "General"),
                    (1, "System"),
                    (2, "Direct Contact"),
                    (3, "Broadcast Email"),
                    (4, "Timed Services"),
                    (5, "Feedback"),
                    (6, "Abuse"),
                    (7, "Safety"),
                    (8, "Tasks"),
                    (9, "Access Requests"),
                    (10, "Sensors"),
                    (11, "Adjustment Requests"),
                    (12, "Training"),
                ],
                default=0,
            ),
        ),
    ]
