# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-09-27 10:26
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import notifications.validators


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='CustomNotifyOptions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('method', models.CharField(blank=True, default='email', max_length=32, null=True)),
                ('msa_user_id', models.IntegerField()),
            ],
            options={
                'verbose_name_plural': 'Custom notify options',
                'verbose_name': 'Custom notify options',
            },
        ),
        migrations.CreateModel(
            name='DefaultNotifyOptions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('method', models.CharField(blank=True, default='email', max_length=32, null=True)),
            ],
            options={
                'verbose_name_plural': 'Default notify options',
                'verbose_name': 'Default notify options',
            },
        ),
        migrations.CreateModel(
            name='Destination',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('app', models.CharField(max_length=100, unique=True)),
                ('mailer_api_url', models.URLField(max_length=255)),
                ('mailer_api_key', models.CharField(max_length=255)),
                ('cas_profile_url', models.URLField(help_text="e.g. http://example.com/api/v1/profile/%d/. '%d' is required for substitute user_id.", max_length=255, validators=[notifications.validators.validate_integer_placeholder])),
                ('cas_api_key', models.CharField(max_length=255)),
                ('comment', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'verbose_name_plural': 'Destinations',
                'verbose_name': 'Destination',
            },
        ),
        migrations.CreateModel(
            name='EventReceiverPath',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('path', models.CharField(help_text='Path to user_id in Event instance, e.g. "context.user.id"', max_length=128, unique=True)),
                ('comment', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'verbose_name_plural': 'Event receiver paths',
                'verbose_name': 'Event receiver path',
            },
        ),
        migrations.CreateModel(
            name='EventTrigger',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('app', models.CharField(max_length=100)),
                ('lookup_kwargs', django.contrib.postgres.fields.jsonb.JSONField()),
                ('comment', models.CharField(blank=True, max_length=255, null=True)),
            ],
            options={
                'verbose_name_plural': 'Event triggers',
                'verbose_name': 'Event trigger',
            },
        ),
        migrations.CreateModel(
            name='Notify',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('template_slug', models.CharField(help_text='Template slug for single event."%s" is required for substitute language code.', max_length=100, validators=[notifications.validators.validate_str_placeholder])),
                ('template_slug_mult', models.CharField(help_text='Template slug for bundle of events (packet delivery)."%s" is required for substitute language code.', max_length=100, validators=[notifications.validators.validate_str_placeholder])),
                ('receiver_path', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='notifications.EventReceiverPath')),
                ('trigger', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifiers', to='notifications.EventTrigger')),
            ],
            options={
                'verbose_name_plural': 'Notifies',
                'verbose_name': 'Notify',
            },
        ),
        migrations.CreateModel(
            name='NotifyTimeOptions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('kind', models.SmallIntegerField(choices=[(0, 'instant'), (1, 'delayed'), (2, 'daily'), (7, 'weekly'), (30, 'monthly')], default=0)),
                ('time', models.TimeField(blank=True, null=True)),
                ('day', models.SmallIntegerField(blank=True, null=True)),
            ],
            options={
                'verbose_name_plural': 'Notify time options',
                'verbose_name': 'Notify time options',
            },
        ),
        migrations.AddField(
            model_name='defaultnotifyoptions',
            name='base',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='default_options', to='notifications.Notify'),
        ),
        migrations.AddField(
            model_name='defaultnotifyoptions',
            name='when',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='notifications.NotifyTimeOptions'),
        ),
        migrations.AddField(
            model_name='customnotifyoptions',
            name='base',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='custom_options', to='notifications.Notify'),
        ),
        migrations.AddField(
            model_name='customnotifyoptions',
            name='when',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='notifications.NotifyTimeOptions'),
        ),
        migrations.AlterUniqueTogether(
            name='notify',
            unique_together=set([('trigger', 'receiver_path')]),
        ),
        migrations.AlterUniqueTogether(
            name='defaultnotifyoptions',
            unique_together=set([('base', 'method')]),
        ),
        migrations.AlterUniqueTogether(
            name='customnotifyoptions',
            unique_together=set([('base', 'method', 'msa_user_id')]),
        ),
    ]
