# Generated by Django 5.2.13 on 2026-04-26 21:15

import apps.core.storage.paths
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0021_alter_auditlog_action"),
        ("rims_grants", "0030_awardcloseoutrecord_forced_at_and_more"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name="application",
            name="scholarship_course_choice",
            field=models.CharField(
                blank=True,
                help_text="Scholarship applications: target course / programme name.",
                max_length=255,
            ),
        ),
        migrations.AddField(
            model_name="application",
            name="scholarship_university_choice",
            field=models.ForeignKey(
                blank=True,
                help_text="Scholarship applications: target university (required when call.scholarship_university_required).",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="+",
                to="core.institution",
            ),
        ),
        migrations.AddField(
            model_name="applicationdocument",
            name="is_budget",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="grantcall",
            name="scholarship_cohort_year",
            field=models.PositiveSmallIntegerField(
                blank=True,
                help_text="Scholarship calls only: target cohort intake year (e.g. 2026).",
                null=True,
            ),
        ),
        migrations.AddField(
            model_name="grantcall",
            name="scholarship_course_required",
            field=models.BooleanField(
                default=False,
                help_text="Scholarship calls only: applicant must select a target course.",
            ),
        ),
        migrations.AddField(
            model_name="grantcall",
            name="scholarship_university_required",
            field=models.BooleanField(
                default=False,
                help_text="Scholarship calls only: applicant must select a target university.",
            ),
        ),
        migrations.AlterField(
            model_name="fundingrecord",
            name="reporting_financial_frequency",
            field=models.CharField(
                choices=[
                    ("monthly", "Monthly"),
                    ("quarterly", "Quarterly"),
                    ("semi_annual", "Semi-annual"),
                    ("annual", "Annual"),
                    ("ad_hoc", "Ad hoc"),
                    ("academic_semester", "Per academic semester"),
                    ("academic_year", "Per academic year"),
                ],
                default="quarterly",
                max_length=24,
            ),
        ),
        migrations.AlterField(
            model_name="fundingrecord",
            name="reporting_narrative_frequency",
            field=models.CharField(
                choices=[
                    ("monthly", "Monthly"),
                    ("quarterly", "Quarterly"),
                    ("semi_annual", "Semi-annual"),
                    ("annual", "Annual"),
                    ("ad_hoc", "Ad hoc"),
                    ("academic_semester", "Per academic semester"),
                    ("academic_year", "Per academic year"),
                ],
                default="quarterly",
                max_length=24,
            ),
        ),
        migrations.CreateModel(
            name="AcademicProgressReport",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "period_label",
                    models.CharField(help_text="e.g. 'Sem 1 2026' or 'AY 2026/27'", max_length=64),
                ),
                ("gpa", models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
                ("supervisor_name", models.CharField(blank=True, max_length=255)),
                ("supervisor_signoff_at", models.DateTimeField(blank=True, null=True)),
                ("summary", models.TextField(blank=True)),
                (
                    "transcript",
                    models.FileField(
                        blank=True, null=True, upload_to=apps.core.storage.paths.upload_to_grants
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("submitted", "Submitted"),
                            ("accepted", "Accepted"),
                            ("revision_required", "Revision required"),
                        ],
                        default="submitted",
                        max_length=24,
                    ),
                ),
                ("submitted_at", models.DateTimeField(auto_now_add=True)),
                ("reviewed_at", models.DateTimeField(blank=True, null=True)),
                ("review_comment", models.TextField(blank=True)),
                (
                    "award",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="academic_progress_reports",
                        to="rims_grants.award",
                    ),
                ),
                (
                    "reviewed_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="academic_progress_reports_reviewed",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "submitted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="academic_progress_reports_submitted",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-submitted_at", "-pk"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("award", "period_label"),
                        name="uniq_academic_progress_per_award_period",
                    )
                ],
            },
        ),
    ]
