# Generated by Django 2.0 on 2018-04-13 14:52

import autoslug.fields
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import ej_conversations.utils
import ej_conversations.validators
import model_utils.fields


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('name', models.CharField(help_text='Unique category name. Hint: list of categories is public.', max_length=255, unique=True, verbose_name='Name')),
                ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', slugify=ej_conversations.utils.custom_slugify, unique=True)),
                ('image', models.ImageField(blank=True, null=True, upload_to='conversations/categories', verbose_name='Image')),
                ('image_caption', models.CharField(blank=True, max_length=255, verbose_name='Image caption')),
            ],
            options={
                'verbose_name_plural': 'categories',
            },
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('status', model_utils.fields.StatusField(choices=[('PENDING', 'awaiting moderation'), ('APPROVED', 'approved'), ('REJECTED', 'rejected')], default='PENDING', max_length=100, no_check_for_status=True, verbose_name='status')),
                ('status_changed', model_utils.fields.MonitorField(default=django.utils.timezone.now, monitor='status', verbose_name='status changed')),
                ('content', models.TextField(validators=[django.core.validators.MaxLengthValidator(140)], verbose_name='Content')),
                ('rejection_reason', models.TextField(blank=True, verbose_name='Rejection reason')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Conversation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('title', models.CharField(max_length=255, verbose_name='Title')),
                ('description', models.TextField(verbose_name='Description')),
                ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='title', slugify=ej_conversations.utils.custom_slugify, unique=True)),
                ('is_promoted', models.BooleanField(default=False, verbose_name='Promoted')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='conversations', to='ej_conversations.Category')),
            ],
            options={
                'ordering': ('created',),
            },
        ),
        migrations.CreateModel(
            name='ConversationPhases',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('dialog', models.TextField(blank=True, verbose_name='Dialog')),
                ('response', models.TextField(blank=True, verbose_name='Response')),
                ('position', models.IntegerField(default=0, verbose_name='Position')),
                ('opinion', models.TextField(blank=True, verbose_name='Our Opinion')),
                ('conversation', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='phases', to='ej_conversations.Conversation')),
            ],
        ),
        migrations.CreateModel(
            name='ConversationStyle',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=140, verbose_name='Description')),
                ('background_image', models.ImageField(blank=True, null=True, upload_to='ej-conversations/backgrounds', verbose_name='Background image')),
                ('background_color', models.CharField(blank=True, max_length=7, null=True, validators=[ej_conversations.validators.validate_color], verbose_name='Background color')),
            ],
        ),
        migrations.CreateModel(
            name='Limits',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=140, verbose_name='Description')),
                ('interval', models.IntegerField(default=600, help_text='Inteval in seconds', verbose_name='Reference interval')),
                ('max_comments_in_interval', models.IntegerField(default=3, help_text='Maximum number of comments in the reference interval', verbose_name='Maximum number of posts in an interval')),
                ('max_votes_in_interval', models.IntegerField(default=100, help_text='Maximum number of votes in the reference interval', verbose_name='Maximum number of votes in the given interval')),
                ('max_comments_per_conversation', models.IntegerField(default=5, help_text='Global number of comments', verbose_name='Maximum number of posts')),
            ],
            options={
                'verbose_name_plural': 'Usage limits',
            },
        ),
        migrations.CreateModel(
            name='Stereotype',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=140, unique=True, verbose_name='Name')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('conversations', models.ManyToManyField(related_name='conversations', to='ej_conversations.Conversation')),
            ],
        ),
        migrations.CreateModel(
            name='StereotypeVote',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.IntegerField(choices=[(1, 'Agree'), (0, 'Skip'), (-1, 'Disagree')], verbose_name='Value')),
                ('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stereotype_votes', to='ej_conversations.Comment')),
                ('stereotype', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stereotype_votes', to='ej_conversations.Stereotype')),
            ],
        ),
        migrations.CreateModel(
            name='Vote',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
                ('value', models.IntegerField(choices=[(1, 'Agree'), (0, 'Skip'), (-1, 'Disagree')], help_text='Numeric values: (disagree: -1, skip: 0, agree: 1)', verbose_name='Vote value')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='votes', to=settings.AUTH_USER_MODEL)),
                ('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='ej_conversations.Comment')),
            ],
        ),
        migrations.AddField(
            model_name='conversation',
            name='limits',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='conversations', to='ej_conversations.Limits'),
        ),
        migrations.AddField(
            model_name='conversation',
            name='style',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='conversations', to='ej_conversations.ConversationStyle'),
        ),
        migrations.AddField(
            model_name='comment',
            name='conversation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='ej_conversations.Conversation'),
        ),
        migrations.AlterUniqueTogether(
            name='vote',
            unique_together={('author', 'comment')},
        ),
        migrations.AlterUniqueTogether(
            name='comment',
            unique_together={('conversation', 'content')},
        ),
    ]
