# Generated by Django 5.2.8 on 2025-12-06 15:03

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("groups", "0002_initial"),
        ("maps", "0002_initial"),
        ("nodes", "0002_initial"),
        ("odoo", "0003_initial"),
        ("tasks", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name="manualtask",
            name="assigned_user",
            field=models.ForeignKey(
                blank=True,
                help_text="Optional user responsible for the task.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="assigned_manual_tasks",
                to=settings.AUTH_USER_MODEL,
                verbose_name="Assigned user",
            ),
        ),
        migrations.AddField(
            model_name="manualtask",
            name="location",
            field=models.ForeignKey(
                blank=True,
                help_text="Location associated with this manual task.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="manual_tasks",
                to="maps.location",
                verbose_name="Location",
            ),
        ),
        migrations.AddField(
            model_name="manualtask",
            name="manager",
            field=models.ForeignKey(
                blank=True,
                help_text="User overseeing the task.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="managed_manual_tasks",
                to=settings.AUTH_USER_MODEL,
                verbose_name="Manager",
            ),
        ),
        migrations.AddField(
            model_name="manualtask",
            name="node",
            field=models.ForeignKey(
                blank=True,
                help_text="Node where this manual task should be completed.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="manual_tasks",
                to="nodes.node",
                verbose_name="Node",
            ),
        ),
        migrations.AddField(
            model_name="manualtask",
            name="odoo_products",
            field=models.ManyToManyField(
                blank=True,
                help_text="Products associated with the requested work.",
                related_name="manual_tasks",
                to="odoo.odooproduct",
                verbose_name="Odoo products",
            ),
        ),
        migrations.AddField(
            model_name="taskcategory",
            name="assigned_group",
            field=models.ForeignKey(
                blank=True,
                help_text="Security group typically assigned to this work.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="task_categories_as_assignee",
                to="groups.securitygroup",
                verbose_name="Assigned to group",
            ),
        ),
        migrations.AddField(
            model_name="taskcategory",
            name="manager",
            field=models.ForeignKey(
                blank=True,
                help_text="User responsible for overseeing this category.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="managed_task_categories",
                to=settings.AUTH_USER_MODEL,
                verbose_name="Manager",
            ),
        ),
        migrations.AddField(
            model_name="taskcategory",
            name="odoo_products",
            field=models.ManyToManyField(
                blank=True,
                help_text="Relevant Odoo products for this category.",
                related_name="task_categories",
                to="odoo.odooproduct",
                verbose_name="Odoo products",
            ),
        ),
        migrations.AddField(
            model_name="taskcategory",
            name="requestor_group",
            field=models.ForeignKey(
                blank=True,
                help_text="Security group authorized to request this work.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="task_categories_as_requestor",
                to="groups.securitygroup",
                verbose_name="Requestor group",
            ),
        ),
        migrations.AddField(
            model_name="manualtask",
            name="category",
            field=models.ForeignKey(
                blank=True,
                help_text="Select the standardized category for this work.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="manual_tasks",
                to="tasks.taskcategory",
                verbose_name="Category",
            ),
        ),
        migrations.AddConstraint(
            model_name="manualtask",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    ("node__isnull", False),
                    ("location__isnull", False),
                    _connector="OR",
                ),
                name="manualtask_requires_target",
            ),
        ),
        migrations.AddConstraint(
            model_name="manualtask",
            constraint=models.CheckConstraint(
                condition=models.Q(("scheduled_end__gte", models.F("scheduled_start"))),
                name="manualtask_schedule_order",
            ),
        ),
    ]
