# Generated by Django 5.0.6 on 2024-07-12 11:34

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


class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('core', '0068_calendar_event_amends_unique_constraints'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CalendarAlarm',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('managed_by_app_label', models.CharField(blank=True, editable=False, max_length=255, verbose_name='App label of app responsible for managing this instance')),
                ('extended_data', models.JSONField(default=dict, editable=False)),
                ('action', models.CharField(choices=[('audio', 'Audio'), ('display', 'Display'), ('email', 'Email'), ('procedure', 'Procedure')], default='display', max_length=10, verbose_name='Action')),
                ('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alarms', to='core.calendarevent', verbose_name='Event')),
                ('send_notifications', models.BooleanField(default=False, verbose_name='Send notifications')),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype')),
            ],
            options={
                'verbose_name': 'Calendar alarm',
                'verbose_name_plural': 'Calendar alarms',
            },
        ),
        migrations.CreateModel(
            name='PersonalEventAlarm',
            fields=[
                ('calendaralarm_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.calendaralarm')),
            ],
            options={
                'verbose_name': 'Personal event alarm',
                'verbose_name_plural': 'Personal event alarms',
            },
            bases=('core.calendaralarm',),
        ),
        migrations.AddField(
            model_name='notification',
            name='calendar_alarm',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to='core.calendaralarm', verbose_name='Calendar alarm'),
        ),
        migrations.AddConstraint(
            model_name='notification',
            constraint=models.UniqueConstraint(condition=models.Q(('calendar_alarm__isnull', False)), fields=('calendar_alarm', 'recipient'), name='unique_recipient_per_calendar_alarm'),
        ),
    ]
