# Generated by Django 4.2.11 on 2025-09-22 00:00

from django.db import migrations, models
import django.db.models.deletion
import pretix.base.models.base


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('pretixbase', '0288_invoice_transmission'),
    ]

    operations = [
        migrations.CreateModel(
            name='SortirOrganizerSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('api_enabled', models.BooleanField(default=False, help_text='Activer la vérification via API APRAS', verbose_name='API activée')),
                ('api_mode', models.CharField(choices=[('production', 'Production'), ('test', 'Test')], default='test', max_length=20, verbose_name='Mode API')),
                ('api_token', models.CharField(blank=True, help_text='Token d\'authentification fourni par APRAS', max_length=500, verbose_name='Token API')),
                ('api_timeout', models.IntegerField(default=2, help_text='Timeout en secondes pour les appels API', verbose_name='Timeout API')),
                ('salt', models.CharField(blank=True, help_text='Salt unique pour le hashage SHA-256 des numéros', max_length=100, verbose_name='Salt de hashage')),
                ('prefill_attendee', models.BooleanField(default=False, help_text='Pré-remplir automatiquement les informations du participant', verbose_name='Pré-remplir participant')),
                ('release_on_cancel', models.BooleanField(default=True, help_text='Libérer les numéros utilisés lors de l\'annulation d\'une commande', verbose_name='Libérer à l\'annulation')),
                ('organizer', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sortir_settings', to='pretixbase.organizer')),
            ],
            options={
                'verbose_name': 'Configuration Sortir! organisateur',
                'verbose_name_plural': 'Configurations Sortir! organisateurs',
            },
            bases=(pretix.base.models.base.LoggedModel, models.Model),
        ),
        migrations.CreateModel(
            name='SortirEventSettings',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('enabled', models.BooleanField(default=False, help_text='Activer le tarif Sortir! pour cet événement', verbose_name='Activé')),
                ('event', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sortir_event_settings', to='pretixbase.event')),
            ],
            options={
                'verbose_name': 'Configuration Sortir! événement',
                'verbose_name_plural': 'Configurations Sortir! événements',
            },
        ),
        migrations.CreateModel(
            name='SortirUsage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Date de création')),
                ('sortir_number_hash', models.CharField(db_index=True, help_text='Hash SHA-256 du numéro de carte', max_length=64, verbose_name='Hash du numéro')),
                ('sortir_number_suffix', models.CharField(help_text='4 derniers chiffres pour support', max_length=4, verbose_name='Suffixe du numéro')),
                ('service_key', models.TextField(help_text='Clé de service retournée par l\'API', verbose_name='Clé de service')),
                ('status', models.CharField(choices=[('validated', 'Validé'), ('used', 'Utilisé'), ('cancelled', 'Annulé')], db_index=True, max_length=20, verbose_name='Statut')),
                ('validated_at', models.DateTimeField(blank=True, null=True, verbose_name='Date de validation')),
                ('used_at', models.DateTimeField(blank=True, null=True, verbose_name='Date d\'utilisation')),
                ('apras_request_id', models.CharField(blank=True, help_text='ID de la demande côté APRAS', max_length=50, null=True, verbose_name='ID demande APRAS')),
                ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sortir_usages', to='pretixbase.event', verbose_name='Événement')),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='pretixbase.item', verbose_name='Produit')),
                ('order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sortir_usages', to='pretixbase.order', verbose_name='Commande')),
                ('variation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='pretixbase.itemvariation', verbose_name='Variation')),
            ],
            options={
                'verbose_name': 'Utilisation Sortir!',
                'verbose_name_plural': 'Utilisations Sortir!',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['event', 'sortir_number_hash'], name='pretix_sort_event_i_5b5c5f_idx'), models.Index(fields=['order', 'status'], name='pretix_sort_order_i_e5c0c9_idx')],
            },
        ),
        migrations.CreateModel(
            name='SortirItemConfig',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('requires_sortir', models.BooleanField(default=False, help_text='Ce tarif nécessite une validation Sortir!', verbose_name='Validation Sortir! requise')),
                ('sortir_price', models.DecimalField(decimal_places=2, help_text='Prix réduit avec le tarif Sortir!', max_digits=10, verbose_name='Prix Sortir!')),
                ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sortir_configs', to='pretixbase.event', verbose_name='Événement')),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pretixbase.item', verbose_name='Produit')),
                ('variation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pretixbase.itemvariation', verbose_name='Variation')),
            ],
            options={
                'verbose_name': 'Configuration item Sortir!',
                'verbose_name_plural': 'Configurations items Sortir!',
                'unique_together': {('event', 'item', 'variation')},
            },
        ),
    ]