# Generated by Django 3.2.19 on 2023-12-28 18:48

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('configuracion_telefonia_app', '0019_tipo_destino_entrante_menuwhatsapp'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('ominicontacto_app', '0103_whatsapp_configuracion_y_canalidad'),
    ]

    operations = [
        migrations.CreateModel(
            name='ConfiguracionProveedor',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('nombre', models.CharField(max_length=100)),
                ('tipo_proveedor', models.IntegerField(
                    choices=[(0, 'Twilio'), (1, 'Meta'), (2, 'GupShup')])),
                ('configuracion', models.JSONField(default=dict)),
                ('created_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='configuracionproveedor_created',
                                                 to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='configuracionproveedor_updated',
                                                 to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ConversacionWhatsapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('destination', models.CharField(max_length=100)),
                ('whatsapp_id', models.CharField(max_length=100, null=True)),
                ('is_active', models.BooleanField(default=False)),
                ('is_disposition', models.BooleanField(default=False)),
                ('expire', models.DateTimeField(null=True)),
                ('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
                ('saliente', models.BooleanField(default=False)),
                ('atendida', models.BooleanField(default=False)),
                ('error', models.BooleanField(default=False)),
                ('date_last_interaction', models.DateTimeField(null=True)),
                ('agent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
                                            related_name='conversaciones',
                                            to='ominicontacto_app.agenteprofile')),
                ('campana', models.ForeignKey(null=True,
                                              on_delete=django.db.models.deletion.CASCADE,
                                              related_name='conversaciones',
                                              to='ominicontacto_app.campana')),
                ('client', models.ForeignKey(null=True,
                                             on_delete=django.db.models.deletion.CASCADE,
                                             related_name='conversaciones',
                                             to='ominicontacto_app.contacto')),
            ],
        ),
        migrations.CreateModel(
            name='Linea',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('nombre', models.CharField(max_length=100)),
                ('numero', models.CharField(max_length=100)),
                ('configuracion', models.JSONField(default=dict)),
                ('created_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='linea_created',
                                                 to=settings.AUTH_USER_MODEL)),
                ('destino', models.ForeignKey(blank=True, null=True,
                                              on_delete=django.db.models.deletion.CASCADE,
                                              related_name='lineas',
                                              to='configuracion_telefonia_app.destinoentrante')),
                ('horario', models.ForeignKey(blank=True, null=True,
                                              on_delete=django.db.models.deletion.CASCADE,
                                              related_name='lineas',
                                              to='configuracion_telefonia_app.grupohorario')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='MenuInteractivoWhatsapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('texto_opciones', models.CharField(max_length=100)),
                ('texto_opcion_incorrecta', models.CharField(max_length=100)),
                ('texto_derivacion', models.CharField(max_length=100)),
                ('timeout', models.IntegerField()),
            ],
        ),
        migrations.CreateModel(
            name='TemplateWhatsapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('nombre', models.CharField(max_length=100)),
                ('identificador', models.CharField(max_length=100)),
                ('texto', models.TextField(blank=True, null=True)),
                ('idioma', models.CharField(max_length=100)),
                ('status', models.CharField(max_length=100)),
                ('creado', models.CharField(max_length=100)),
                ('modificado', models.CharField(max_length=100)),
                ('tipo', models.CharField(max_length=100)),
                ('categoria', models.CharField(max_length=100)),
                ('is_active', models.BooleanField(default=True)),
                ('linea', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                            related_name='templates_whatsapp',
                                            to='whatsapp_app.linea')),
            ],
        ),
        migrations.CreateModel(
            name='PlantillaMensaje',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('nombre', models.CharField(max_length=100)),
                ('tipo', models.IntegerField(choices=[(0, 'Texto'), (1, 'Imagen')])),
                ('configuracion', models.JSONField(default=dict)),
                ('created_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='plantillamensaje_created',
                                                 to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='plantillamensaje_updated',
                                                 to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='OpcionMenuInteractivoWhatsapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('descripcion', models.CharField(max_length=100)),
                ('opcion', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE,
                                                related_name='opcion_menu_whatsapp',
                                                to='configuracion_telefonia_app.opciondestino')),
            ],
        ),
        migrations.CreateModel(
            name='MensajeWhatsapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('message_id', models.CharField(max_length=100)),
                ('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
                ('origen', models.CharField(max_length=100)),
                ('sender', models.JSONField(default=dict)),
                ('content', models.JSONField(default=dict)),
                ('type', models.CharField(max_length=100)),
                ('status', models.CharField(max_length=100)),
                ('conversation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                                   related_name='mensajes',
                                                   to='whatsapp_app.conversacionwhatsapp')),
            ],
        ),
        migrations.AddField(
            model_name='linea',
            name='mensaje_bienvenida',
            field=models.ForeignKey(blank=True, null=True,
                                    on_delete=django.db.models.deletion.CASCADE,
                                    related_name='linea_mensaje_bienvenida',
                                    to='whatsapp_app.plantillamensaje'),
        ),
        migrations.AddField(
            model_name='linea',
            name='mensaje_despedida',
            field=models.ForeignKey(blank=True, null=True,
                                    on_delete=django.db.models.deletion.CASCADE,
                                    related_name='linea_mensaje_despedida',
                                    to='whatsapp_app.plantillamensaje'),
        ),
        migrations.AddField(
            model_name='linea',
            name='mensaje_fueradehora',
            field=models.ForeignKey(blank=True, null=True,
                                    on_delete=django.db.models.deletion.CASCADE,
                                    related_name='linea_mensaje_fueradehora',
                                    to='whatsapp_app.plantillamensaje'),
        ),
        migrations.AddField(
            model_name='linea',
            name='proveedor',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                    related_name='lineas',
                                    to='whatsapp_app.configuracionproveedor'),
        ),
        migrations.AddField(
            model_name='linea',
            name='updated_by',
            field=models.ForeignKey(default='',
                                    on_delete=django.db.models.deletion.PROTECT,
                                    related_name='linea_updated',
                                    to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='GrupoPlantillaMensaje',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('nombre', models.CharField(max_length=100)),
                ('created_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='grupoplantillamensaje_created',
                                                 to=settings.AUTH_USER_MODEL)),
                ('plantillas', models.ManyToManyField(to='whatsapp_app.PlantillaMensaje')),
                ('updated_by', models.ForeignKey(default='',
                                                 on_delete=django.db.models.deletion.PROTECT,
                                                 related_name='grupoplantillamensaje_updated',
                                                 to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='conversacionwhatsapp',
            name='line',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                    related_name='conversaciones',
                                    to='whatsapp_app.linea'),
        ),
        migrations.CreateModel(
            name='ConfiguracionWhatsappCampana',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('nivel_servicio', models.IntegerField()),
                ('campana', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                              related_name='configuracionwhatsapp',
                                              to='ominicontacto_app.campana')),
                ('created_by', models.ForeignKey(
                    default='', on_delete=django.db.models.deletion.PROTECT,
                    related_name='configuracionwhatsappcampana_created',
                    to=settings.AUTH_USER_MODEL)),
                ('grupo_plantilla_whatsapp', models.ForeignKey(
                    on_delete=django.db.models.deletion.CASCADE,
                    related_name='configuracionwhatsapp',
                    to='whatsapp_app.grupoplantillamensaje')),
                ('linea', models.ForeignKey(blank=True, null=True,
                                            on_delete=django.db.models.deletion.CASCADE,
                                            related_name='configuracionwhatsapp',
                                            to='whatsapp_app.linea')),
                ('updated_by', models.ForeignKey(
                    default='',
                    on_delete=django.db.models.deletion.PROTECT,
                    related_name='configuracionwhatsappcampana_updated',
                    to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddConstraint(
            model_name='templatewhatsapp',
            constraint=models.UniqueConstraint(fields=('linea_id', 'identificador'),
                                               name='identificador_unico'),
        ),
    ]
