# Generated by Django 5.2.1 on 2026-07-23 07:02

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


class Migration(migrations.Migration):

    dependencies = [
        ('certifications', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='certificationapplication',
            name='payment_kind',
            field=models.CharField(default='initial', help_text='initial or reattempt — which fee the current proof/Stripe session is for.', max_length=20),
        ),
        migrations.AddField(
            model_name='certificationapplication',
            name='proctor_unlocked_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='certificationprogram',
            name='meeting_instructions',
            field=models.TextField(blank=True, help_text='How candidates join the live proctor meeting (Zoom/Meet link, schedule notes, etc.).'),
        ),
        migrations.AddField(
            model_name='certificationprogram',
            name='reattempt_fee',
            field=models.DecimalField(blank=True, decimal_places=2, help_text='Fee for each reattempt after a fail. Leave blank to use half of the certification fee.', max_digits=8, null=True),
        ),
        migrations.AddField(
            model_name='certificationprogram',
            name='require_proctor',
            field=models.BooleanField(default=True, help_text='Remote exams must be unlocked with a live teacher/consultant meeting code.'),
        ),
        migrations.AlterField(
            model_name='certificationapplication',
            name='status',
            field=models.CharField(choices=[('pending_payment', 'Pending certification fee'), ('paid', 'Paid — join proctor meeting'), ('awaiting_proctor', 'Proctor unlocked — start exam'), ('in_exam', 'Exam in progress'), ('passed', 'Passed'), ('failed', 'Failed'), ('pending_reattempt_payment', 'Pending reattempt fee'), ('certified', 'Certificate issued')], default='pending_payment', max_length=40),
        ),
        migrations.AlterField(
            model_name='certificationprogram',
            name='fee',
            field=models.DecimalField(decimal_places=2, default=0, help_text='Initial certification fee (set by admin).', max_digits=8),
        ),
        migrations.AlterField(
            model_name='certificationprogram',
            name='max_attempts',
            field=models.PositiveIntegerField(default=3, help_text='Total exam attempts allowed (1 initial + 2 reattempts if failed). 0 = unlimited.'),
        ),
        migrations.AlterField(
            model_name='certificationprogram',
            name='passing_score',
            field=models.PositiveIntegerField(default=70, help_text='Minimum percentage required to pass (default 70%).'),
        ),
        migrations.CreateModel(
            name='ProctorSession',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=16, unique=True)),
                ('meeting_url', models.URLField(blank=True, help_text='Optional Zoom/Meet/Teams link for this session.')),
                ('notes', models.CharField(blank=True, max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('expires_at', models.DateTimeField()),
                ('unlocked_at', models.DateTimeField(blank=True, null=True)),
                ('is_revoked', models.BooleanField(default=False)),
                ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='proctor_sessions', to='certifications.certificationapplication')),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_proctor_sessions', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddField(
            model_name='examattempt',
            name='proctor_session',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='attempts', to='certifications.proctorsession'),
        ),
    ]
