# Generated by Django 4.2.29 on 2026-03-11 14:36

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="OnlineTraining",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=255, unique=True)),
                (
                    "enabled",
                    models.BooleanField(
                        default=True, help_text="If unchecked, this training will not be available to users"
                    ),
                ),
                (
                    "completion_time_limit",
                    models.PositiveIntegerField(
                        default=120,
                        help_text="The maximum time the user can take to complete the training on the page (in minutes)",
                    ),
                ),
                (
                    "is_blocking",
                    models.BooleanField(
                        default=False,
                        help_text="If checked, prevents the linked NEMO user from performing other actions until this training is completed",
                    ),
                ),
                (
                    "allow_self_enrollment",
                    models.BooleanField(
                        default=False, help_text="Allow users to take this training without prior assignment."
                    ),
                ),
                (
                    "html_content",
                    models.TextField(
                        blank=True,
                        help_text="The HTML content of the training. The following context variables are available:<ul style='padding-left: 35px;'><li style='list-style: initial'><b>training_user</b>: the user</li><li style='list-style: initial'><b>training</b>: this training</li><li style='list-style: initial'><b>record</b>: the completion record</li></ul>Upon completion, call the JS function: <code>training_completed(dict_data)</code>",
                        null=True,
                    ),
                ),
                ("creation_time", models.DateTimeField(auto_now_add=True)),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="ProspectiveUser",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("creation_time", models.DateTimeField(auto_now_add=True)),
                ("last_updated", models.DateTimeField(auto_now=True)),
                ("last_accessed", models.DateTimeField(blank=True, null=True)),
                (
                    "_first_name",
                    models.CharField(
                        blank=True, db_column="first_name", max_length=100, null=True, verbose_name="First name"
                    ),
                ),
                (
                    "_last_name",
                    models.CharField(
                        blank=True, db_column="last_name", max_length=100, null=True, verbose_name="Last name"
                    ),
                ),
                (
                    "_email",
                    models.EmailField(
                        blank=True, db_column="email", max_length=254, null=True, verbose_name="Email address"
                    ),
                ),
                (
                    "nemo_user",
                    models.OneToOneField(
                        blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
                    ),
                ),
            ],
            options={
                "ordering": ["_first_name", "_last_name", "nemo_user__first_name", "nemo_user__last_name"],
            },
        ),
        migrations.CreateModel(
            name="OnlineUserTraining",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "due_date",
                    models.DateTimeField(blank=True, help_text="The due date/time for the training", null=True),
                ),
                (
                    "start",
                    models.DateTimeField(blank=True, help_text="The date/time the training was started", null=True),
                ),
                (
                    "end",
                    models.DateTimeField(blank=True, help_text="The date/time the training was completed", null=True),
                ),
                (
                    "completion_data",
                    models.JSONField(
                        blank=True,
                        help_text="Completion data to be stored for the training, like answers to questions",
                        null=True,
                    ),
                ),
                ("creation_time", models.DateTimeField(auto_now_add=True)),
                ("last_updated", models.DateTimeField(auto_now=True)),
                (
                    "online_training",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="NEMO_online_training.onlinetraining"
                    ),
                ),
                (
                    "prospective_user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="NEMO_online_training.prospectiveuser"
                    ),
                ),
            ],
            options={
                "ordering": ["-end", "-due_date"],
            },
        ),
        migrations.CreateModel(
            name="OnlineTrainingAction",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("action_type", models.CharField(max_length=100)),
                (
                    "configuration",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Enter configuration as JSON. See <a href='https://github.com/usnistgov/NEMO-online-training?tab=readme-ov-file#usage' target='_blank'>this link</a> for more information.",
                    ),
                ),
                (
                    "user_filter",
                    NEMO_online_training.fields.UserTypeFilterField(
                        default="all_nemo,prospective",
                        help_text="Select which users this action applies to. You can select 'All NEMO users', specific user types, and/or new users (without NEMO accounts).",
                    ),
                ),
                (
                    "online_training",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="NEMO_online_training.onlinetraining"
                    ),
                ),
            ],
            options={
                "ordering": ["action_type"],
            },
        ),
    ]
