# Generated by Django 5.2.8 on 2025-11-28 10:22

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


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0007_add_tenant_permissions'),
        ('tickets', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CannedResponse',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(help_text='Short title for easy selection.', max_length=100)),
                ('content', models.TextField(help_text='The response content. Can include placeholders.')),
                ('category', models.CharField(blank=True, choices=[('BILLING', 'Billing & Payments'), ('TECHNICAL', 'Technical Issue'), ('FEATURE_REQUEST', 'Feature Request'), ('ACCOUNT', 'Account & Settings'), ('APPOINTMENT', 'Appointment Issue'), ('REFUND', 'Refund Request'), ('COMPLAINT', 'Complaint'), ('GENERAL_INQUIRY', 'General Inquiry'), ('TIME_OFF', 'Time Off Request'), ('SCHEDULE_CHANGE', 'Schedule Change'), ('EQUIPMENT', 'Equipment Issue'), ('OTHER', 'Other')], help_text='Category this response is most relevant to.', max_length=50)),
                ('is_active', models.BooleanField(default=True)),
                ('use_count', models.PositiveIntegerField(default=0, help_text='Number of times this response was used.')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'ordering': ['-use_count', 'title'],
            },
        ),
        migrations.CreateModel(
            name='TicketTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Template name.', max_length=100)),
                ('description', models.TextField(blank=True, help_text='Description of when to use this template.')),
                ('ticket_type', models.CharField(choices=[('PLATFORM', 'Platform Support'), ('CUSTOMER', 'Customer Inquiry'), ('STAFF_REQUEST', 'Staff Request'), ('INTERNAL', 'Internal Business Ticket')], help_text='Type of ticket this template creates.', max_length=20)),
                ('category', models.CharField(choices=[('BILLING', 'Billing & Payments'), ('TECHNICAL', 'Technical Issue'), ('FEATURE_REQUEST', 'Feature Request'), ('ACCOUNT', 'Account & Settings'), ('APPOINTMENT', 'Appointment Issue'), ('REFUND', 'Refund Request'), ('COMPLAINT', 'Complaint'), ('GENERAL_INQUIRY', 'General Inquiry'), ('TIME_OFF', 'Time Off Request'), ('SCHEDULE_CHANGE', 'Schedule Change'), ('EQUIPMENT', 'Equipment Issue'), ('OTHER', 'Other')], default='OTHER', max_length=50)),
                ('default_priority', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('URGENT', 'Urgent')], default='MEDIUM', max_length=20)),
                ('subject_template', models.CharField(help_text='Default subject line. Can include placeholders like {customer_name}.', max_length=255)),
                ('description_template', models.TextField(help_text='Default description. Can include placeholders.')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'ordering': ['ticket_type', 'name'],
            },
        ),
        migrations.AddField(
            model_name='ticket',
            name='due_at',
            field=models.DateTimeField(blank=True, help_text='SLA deadline based on priority.', null=True),
        ),
        migrations.AddField(
            model_name='ticket',
            name='first_response_at',
            field=models.DateTimeField(blank=True, help_text='When the first response was made.', null=True),
        ),
        migrations.AddField(
            model_name='ticket',
            name='related_appointment_id',
            field=models.CharField(blank=True, help_text='ID of the related appointment for customer inquiry tickets.', max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='ticket',
            name='category',
            field=models.CharField(choices=[('BILLING', 'Billing & Payments'), ('TECHNICAL', 'Technical Issue'), ('FEATURE_REQUEST', 'Feature Request'), ('ACCOUNT', 'Account & Settings'), ('APPOINTMENT', 'Appointment Issue'), ('REFUND', 'Refund Request'), ('COMPLAINT', 'Complaint'), ('GENERAL_INQUIRY', 'General Inquiry'), ('TIME_OFF', 'Time Off Request'), ('SCHEDULE_CHANGE', 'Schedule Change'), ('EQUIPMENT', 'Equipment Issue'), ('OTHER', 'Other')], default='OTHER', help_text='Category of the ticket.', max_length=50),
        ),
        migrations.AlterField(
            model_name='ticket',
            name='status',
            field=models.CharField(choices=[('OPEN', 'Open'), ('IN_PROGRESS', 'In Progress'), ('AWAITING_RESPONSE', 'Awaiting Response'), ('RESOLVED', 'Resolved'), ('CLOSED', 'Closed')], default='OPEN', help_text='Current status of the ticket.', max_length=20),
        ),
        migrations.AlterField(
            model_name='ticket',
            name='ticket_type',
            field=models.CharField(choices=[('PLATFORM', 'Platform Support'), ('CUSTOMER', 'Customer Inquiry'), ('STAFF_REQUEST', 'Staff Request'), ('INTERNAL', 'Internal Business Ticket')], default='CUSTOMER', help_text='Distinguishes between platform support tickets and customer/staff tickets.', max_length=20),
        ),
        migrations.AddIndex(
            model_name='ticket',
            index=models.Index(fields=['creator', 'status'], name='tickets_tic_creator_cc6043_idx'),
        ),
        migrations.AddIndex(
            model_name='ticket',
            index=models.Index(fields=['category'], name='tickets_tic_categor_fc7dd1_idx'),
        ),
        migrations.AddField(
            model_name='cannedresponse',
            name='created_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_canned_responses', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='cannedresponse',
            name='tenant',
            field=models.ForeignKey(blank=True, help_text='Tenant this response belongs to. Null for platform-wide responses.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='canned_responses', to='core.tenant'),
        ),
        migrations.AddField(
            model_name='tickettemplate',
            name='tenant',
            field=models.ForeignKey(blank=True, help_text='Tenant this template belongs to. Null for platform-wide templates.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='ticket_templates', to='core.tenant'),
        ),
    ]
