# -*- coding: utf-8 -*-
# Generated by Django 1.9.3 on 2016-04-04 12:14
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.hstore
import django.contrib.postgres.fields.jsonb
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import munch.apps.contacts.validators
import munch.core.utils.models
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CollectedContact',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('properties', django.contrib.postgres.fields.hstore.HStoreField(default={}, verbose_name='propriétés')),
                ('address', models.EmailField(max_length=254, verbose_name='adresse e-mail')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='date de création')),
                ('update_date', models.DateTimeField(auto_now=True, verbose_name='date de modification')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)),
                ('status', models.CharField(choices=[('pending', 'en attente'), ('bounced', 'échec bounce'), ('expired', 'expiré'), ('ok', 'ok'), ('consumed', 'consommé')], default='pending', max_length=50, verbose_name='statut')),
                ('subscription_ip', models.GenericIPAddressField(default='127.0.0.1', verbose_name='adresse IP d’envoi')),
            ],
            options={
                'verbose_name': 'adresse collectée',
                'verbose_name_plural': 'adresses collectées',
            },
            bases=(models.Model, munch.core.utils.models.OwnedModelMixin),
        ),
        migrations.CreateModel(
            name='Contact',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('properties', django.contrib.postgres.fields.hstore.HStoreField(default={}, verbose_name='propriétés')),
                ('address', models.EmailField(max_length=254, verbose_name='adresse e-mail')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='date de création')),
                ('update_date', models.DateTimeField(auto_now=True, verbose_name='date de modification')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)),
                ('status', models.CharField(choices=[('pending', 'en attente'), ('bounced', 'échec bounce'), ('expired', 'expiré'), ('ok', 'ok'), ('consumed', 'consommé')], default='pending', max_length=50, verbose_name='statut')),
                ('subscription_ip', models.GenericIPAddressField(default='127.0.0.1', verbose_name='adresse IP d’envoi')),
            ],
            bases=(models.Model, munch.core.utils.models.OwnedModelMixin),
        ),
        migrations.CreateModel(
            name='ContactList',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('properties', django.contrib.postgres.fields.hstore.HStoreField(default={}, verbose_name='propriétés')),
                ('source_type', models.CharField(blank=True, max_length=100, validators=[django.core.validators.RegexValidator(message='source should be composed of lowercase letters and dashes', regex='^[a-z-]*$')])),
                ('source_ref', models.CharField(blank=True, max_length=200)),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)),
                ('name', models.CharField(max_length=100, verbose_name='nom')),
                ('contact_fields', django.contrib.postgres.fields.jsonb.JSONField(default=[{'name': 'Prénom', 'required': False, 'type': 'Char'}, {'name': 'Nom', 'required': False, 'type': 'Char'}], validators=[munch.apps.contacts.validators.properties_schema_validator], verbose_name='champs des contacts')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='auteur')),
            ],
            options={
                'verbose_name': 'liste de contacts',
                'verbose_name_plural': 'listes de contacts',
            },
            bases=(models.Model, munch.core.utils.models.OwnedModelMixin),
        ),
        migrations.CreateModel(
            name='ContactListPolicy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='nom')),
                ('description', models.TextField(verbose_name='description')),
            ],
            options={
                'verbose_name': 'politique de file',
                'verbose_name_plural': 'politiques de files',
            },
        ),
        migrations.CreateModel(
            name='ContactListPolicyAttribution',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('contact_list', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contacts.ContactList')),
                ('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contacts.ContactListPolicy')),
            ],
        ),
        migrations.CreateModel(
            name='ContactQueue',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('properties', django.contrib.postgres.fields.hstore.HStoreField(default={}, verbose_name='propriétés')),
                ('source_type', models.CharField(blank=True, max_length=100, validators=[django.core.validators.RegexValidator(message='source should be composed of lowercase letters and dashes', regex='^[a-z-]*$')])),
                ('source_ref', models.CharField(blank=True, max_length=200)),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)),
                ('contact_fields', django.contrib.postgres.fields.jsonb.JSONField(default=[], validators=[munch.apps.contacts.validators.properties_schema_validator], verbose_name='champs des contacts')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='auteur')),
            ],
            options={
                'abstract': False,
            },
            bases=(models.Model, munch.core.utils.models.OwnedModelMixin),
        ),
        migrations.CreateModel(
            name='ContactQueuePolicyAttribution',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('contact_queue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contacts.ContactQueue')),
                ('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contacts.ContactListPolicy')),
            ],
        ),
        migrations.AddField(
            model_name='contactqueue',
            name='policies',
            field=models.ManyToManyField(through='contacts.ContactQueuePolicyAttribution', to='contacts.ContactListPolicy', verbose_name='politiques de la file'),
        ),
        migrations.AddField(
            model_name='contactlist',
            name='policies',
            field=models.ManyToManyField(through='contacts.ContactListPolicyAttribution', to='contacts.ContactListPolicy', verbose_name='politiques de la file'),
        ),
        migrations.AddField(
            model_name='contact',
            name='contact_list',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='contacts.ContactList'),
        ),
        migrations.AddField(
            model_name='collectedcontact',
            name='contact_queue',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='collected_contacts', to='contacts.ContactQueue'),
        ),
        migrations.AlterUniqueTogether(
            name='contactqueuepolicyattribution',
            unique_together=set([('policy', 'contact_queue')]),
        ),
        migrations.AlterUniqueTogether(
            name='contactlistpolicyattribution',
            unique_together=set([('policy', 'contact_list')]),
        ),
        migrations.AlterUniqueTogether(
            name='contactlist',
            unique_together=set([('author', 'name')]),
        ),
        migrations.AlterUniqueTogether(
            name='contact',
            unique_together=set([('contact_list', 'address')]),
        ),
        migrations.AlterUniqueTogether(
            name='collectedcontact',
            unique_together=set([('contact_queue', 'address')]),
        ),
    ]
