# Generated by Django 4.2.27 on 2026-01-11 22:43

import NEMO.utilities
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),
        ("NEMO_billing", "0009_corefacility_external_id"),
    ]

    operations = [
        migrations.CreateModel(
            name="InstitutionAgreement",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "agreement_id",
                    models.CharField(help_text="The unique ID for this agreement", max_length=255, unique=True),
                ),
                ("name", models.CharField(help_text="The name of the agreement", max_length=255)),
                ("start_date", models.DateField(help_text="The date this agreement goes into effect.")),
                (
                    "expiration_date",
                    models.DateField(blank=True, help_text="The date this agreement expires.", null=True),
                ),
                (
                    "reminder_date",
                    models.DateField(
                        blank=True,
                        help_text="The date to send a reminder about this agreement's expiration.",
                        null=True,
                    ),
                ),
                (
                    "point_of_contact_name",
                    models.CharField(help_text="The name of the point of contact for this agreement.", max_length=255),
                ),
                (
                    "point_of_contact_email",
                    models.EmailField(
                        help_text="The email address of the point of contact for this agreement.", max_length=255
                    ),
                ),
                (
                    "core_facilities",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Core facilities that are covered under this agreement.",
                        to="NEMO_billing.corefacility",
                    ),
                ),
                (
                    "institution",
                    models.ForeignKey(
                        help_text="The institution this agreement is for",
                        on_delete=django.db.models.deletion.PROTECT,
                        to="NEMO_billing.institution",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        help_text="The owner of this agreement.",
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="InstitutionAgreementDocuments",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "document",
                    models.FileField(
                        blank=True,
                        max_length=255,
                        null=True,
                        upload_to=NEMO.utilities.document_filename_upload,
                        verbose_name="Document",
                    ),
                ),
                ("url", models.URLField(blank=True, null=True, verbose_name="URL")),
                (
                    "name",
                    models.CharField(
                        blank=True,
                        help_text="The optional name to display for this document",
                        max_length=255,
                        null=True,
                    ),
                ),
                (
                    "display_order",
                    models.IntegerField(
                        default=1,
                        help_text="The order in which the documents will be listed. Lower values are displayed first.",
                    ),
                ),
                ("uploaded_at", models.DateTimeField(auto_now_add=True)),
                (
                    "agreement",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="institution_agreements.institutionagreement"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Service agreement documents",
                "ordering": ["display_order", "-uploaded_at"],
                "abstract": False,
            },
        ),
    ]
