# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2017-04-17 05:45
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='Ballot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date_cast', models.DateTimeField(auto_now=True)),
                ('owned_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='BallotItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.IntegerField()),
                ('ballot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constellation_vote.Ballot')),
            ],
            options={
                'ordering': ['order'],
            },
        ),
        migrations.CreateModel(
            name='Poll',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=128)),
                ('desc', models.TextField(blank=True, null=True)),
                ('starts', models.DateTimeField(auto_now=True)),
                ('ends', models.DateTimeField(blank=True, null=True)),
                ('results_visible', models.BooleanField(default=False)),
                ('ip_range', models.TextField(default='0.0.0.0/0')),
                ('mechanism', models.IntegerField(default=-1)),
                ('required_winners', models.IntegerField(default=1)),
                ('cast_multiple', models.BooleanField(default=True)),
                ('archived', models.BooleanField(default=False)),
                ('owned_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
            ],
            options={
                'permissions': (('poll_owned_by', 'Poll Owner'), ('poll_visible', 'Poll is Visible')),
            },
        ),
        migrations.CreateModel(
            name='PollOption',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.CharField(blank=True, max_length=75, null=True)),
                ('desc', models.TextField(blank=True, null=True)),
                ('active', models.BooleanField(default=True)),
                ('poll', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='constellation_vote.Poll')),
            ],
        ),
        migrations.AddField(
            model_name='ballotitem',
            name='poll_option',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constellation_vote.PollOption'),
        ),
        migrations.AddField(
            model_name='ballot',
            name='poll',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='constellation_vote.Poll'),
        ),
        migrations.AddField(
            model_name='ballot',
            name='selected_options',
            field=models.ManyToManyField(through='constellation_vote.BallotItem', to='constellation_vote.PollOption'),
        ),
        migrations.AlterUniqueTogether(
            name='ballotitem',
            unique_together=set([('ballot', 'poll_option'), ('ballot', 'order')]),
        ),
        migrations.AlterUniqueTogether(
            name='ballot',
            unique_together=set([('poll', 'owned_by')]),
        ),
    ]
