# Part 8 ASAP — featured/sale/bundles + diagnostic leads (NOT APPLIED YET)
# Review, then: python manage.py migrate courses 0012
# Deferred: referrals, corporate bulk, installments, retake bundles

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('courses', '0011_practical_submissions'),
    ]

    operations = [
        migrations.CreateModel(
            name='CourseBundle',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('slug', models.SlugField(blank=True, max_length=220, unique=True)),
                ('description', models.TextField(blank=True)),
                ('discount_percent', models.PositiveSmallIntegerField(default=10, help_text='Discount vs sum of member exam fees.')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'verbose_name': 'Course bundle',
                'verbose_name_plural': 'Course bundles',
                'ordering': ['name'],
            },
        ),
        migrations.AddField(
            model_name='course',
            name='is_featured',
            field=models.BooleanField(db_index=True, default=False, help_text='Highlight on home and course listings.'),
        ),
        migrations.AddField(
            model_name='course',
            name='discount_price',
            field=models.DecimalField(blank=True, decimal_places=2, help_text='Sale / promo exam price. When set and lower than exam_fee, shown as the offer price.', max_digits=10, null=True),
        ),
        migrations.AddField(
            model_name='course',
            name='bundle',
            field=models.ForeignKey(blank=True, help_text='Optional multi-course bundle this track belongs to.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='courses', to='courses.coursebundle'),
        ),
        migrations.CreateModel(
            name='DiagnosticAttempt',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('email', models.EmailField(max_length=254)),
                ('whatsapp', models.CharField(blank=True, max_length=30)),
                ('score', models.DecimalField(decimal_places=2, max_digits=5)),
                ('correct_count', models.PositiveIntegerField(default=0)),
                ('total_asked', models.PositiveIntegerField(default=0)),
                ('question_ids', models.JSONField(blank=True, default=list)),
                ('taken_at', models.DateTimeField(auto_now_add=True)),
                ('follow_up_sent', models.BooleanField(default=False, help_text='Mark when a discount / nurture message has been sent.')),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='diagnostic_attempts', to='courses.course')),
            ],
            options={
                'verbose_name': 'Diagnostic attempt',
                'verbose_name_plural': 'Diagnostic attempts',
                'ordering': ['-taken_at'],
            },
        ),
    ]
