# Generated by Django 3.2.25 on 2026-04-15 18:07

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Evenement',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nom', models.CharField(max_length=200, verbose_name="Nom de l'événement")),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('date', models.DateTimeField(verbose_name="Date et heure de l'événement")),
                ('image_background', models.ImageField(blank=True, help_text='Image qui apparaîtra sur le site et potentiellement sur le ticket.', null=True, upload_to='evenements_bg/', verbose_name='Image de fond')),
                ('est_actif', models.BooleanField(default=True, help_text="Décocher pour cacher l'événement du site public.", verbose_name='Actif / Visible')),
                ('date_creation', models.DateTimeField(auto_now_add=True)),
                ('date_modification', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': 'Événement',
                'verbose_name_plural': 'Événements',
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='TypeTicket',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nom', models.CharField(help_text='Ex: Standard, VIP, Pass Famille', max_length=100, verbose_name='Nom du type')),
                ('prix', models.PositiveIntegerField(verbose_name='Prix (en FCFA)')),
                ('avantages', models.TextField(blank=True, help_text='Liste des avantages, séparés par des retours à la ligne.', verbose_name='Avantages inclus')),
                ('usage_unique', models.BooleanField(default=True, help_text='Si décoché, peut être configuré pour plusieurs passages.', verbose_name='Ticket à usage unique')),
                ('evenement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='types_tickets', to='core.evenement', verbose_name='Événement associé')),
            ],
            options={
                'verbose_name': 'Type de Ticket',
                'verbose_name_plural': 'Types de Ticket',
                'unique_together': {('evenement', 'nom')},
            },
        ),
        migrations.CreateModel(
            name='Ticket',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code_unique', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('qr_code', models.ImageField(blank=True, editable=False, null=True, upload_to='qr_codes/')),
                ('client_nom', models.CharField(max_length=150, verbose_name='Nom du client')),
                ('client_contact', models.CharField(blank=True, max_length=100, verbose_name='Contact du client')),
                ('date_emission', models.DateTimeField(auto_now_add=True)),
                ('statut', models.CharField(choices=[('VALIDE', 'Valide'), ('SCANNE', 'Déjà scanné'), ('ANNULE', 'Annulé')], default='VALIDE', max_length=10, verbose_name='Statut')),
                ('nb_scans_autorises', models.PositiveIntegerField(default=1)),
                ('nb_scans_effectues', models.PositiveIntegerField(default=0)),
                ('type_ticket', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tickets_vendus', to='core.typeticket', verbose_name='Type de ticket')),
            ],
            options={
                'verbose_name': 'Ticket',
                'ordering': ['-date_emission'],
            },
        ),
        migrations.CreateModel(
            name='ScanLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date_scan', models.DateTimeField(auto_now_add=True)),
                ('resultat', models.CharField(choices=[('SUCCES', 'Succès - Entrée autorisée'), ('DEJA_UTILISE', 'Avertissement - Déjà scanné'), ('INVALIDE', 'Erreur - Ticket non reconnu ou annulé')], max_length=20, verbose_name='Résultat du scan')),
                ('agent_scan', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scan_logs', to='core.ticket')),
            ],
            options={
                'verbose_name': 'Journal de Scan',
                'verbose_name_plural': 'Journaux de Scan',
                'ordering': ['-date_scan'],
            },
        ),
    ]
