# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2018-11-13 14:18
from __future__ import unicode_literals

from django.db import migrations, models
from configuracion_telefonia_app.models import DestinoEntrante


def crear_nodo_hangup(apps, schema_editor):
    HangUp = apps.get_model("configuracion_telefonia_app", "HangUp")
    hangup, created = HangUp.objects.get_or_create(pk=1)

    kwargs = {
        'nombre': 'HangUp',
        'tipo': DestinoEntrante.HANGUP,
        'content_object': hangup
    }
    return DestinoEntrante.objects.create(**kwargs)


def borrar_nodo_hangup(apps, schema_editor):
    HangUp = apps.get_model("configuracion_telefonia_app", "HangUp")
    hangup = HangUp.objects.get(pk=1)
    destino = DestinoEntrante.objects.get(tipo=DestinoEntrante.HANGUP, nombre='HangUp')
    destino.delete()
    hangup.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('configuracion_telefonia_app', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='HangUp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
                                        verbose_name='ID')),
            ],
        ),
        migrations.RunPython(crear_nodo_hangup, borrar_nodo_hangup),
    ]
