# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-10-29 09:16
from __future__ import unicode_literals

from decimal import Decimal
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='Answer_Type',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name='Campaign',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
                ('creation_date', models.DateTimeField(default=django.utils.timezone.now)),
                ('start_date', models.DateField()),
                ('finish_date', models.DateField()),
                ('start_signup', models.DateField()),
                ('finish_signup', models.DateField()),
                ('init_trustworthiness', models.DecimalField(decimal_places=2, max_digits=4)),
            ],
        ),
        migrations.CreateModel(
            name='Task',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.TextField()),
                ('insert_date', models.DateTimeField(default=django.utils.timezone.now)),
                ('priority', models.IntegerField(default=0)),
                ('final_answer', models.TextField(blank=True, null=True)),
                ('current_round', models.IntegerField(blank=True, null=True)),
                ('answer_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Answer_Type')),
                ('campaign', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Campaign')),
            ],
        ),
        migrations.CreateModel(
            name='Task_Setup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('num_worker', models.IntegerField()),
                ('min_trustworthiness', models.DecimalField(decimal_places=2, max_digits=4)),
                ('consensus_threshold', models.DecimalField(decimal_places=2, max_digits=4)),
                ('max_exec_time', models.IntegerField()),
            ],
        ),
        migrations.CreateModel(
            name='Task_Status',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name='Task_Task_Setup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('round', models.IntegerField()),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Task')),
                ('task_setup', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Task_Setup')),
            ],
        ),
        migrations.CreateModel(
            name='Worker',
            fields=[
                ('id', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
                ('genre', models.CharField(max_length=1)),
                ('birth_date', models.DateField()),
                ('w_score', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5)),
                ('w_trustworthiness', models.DecimalField(decimal_places=2, default=Decimal('1.00'), max_digits=4)),
                ('banned', models.BooleanField(default=False)),
            ],
        ),
        migrations.CreateModel(
            name='Worker_Campaign',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('c_score', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5)),
                ('c_trustworthiness', models.DecimalField(decimal_places=2, default=Decimal('1.00'), max_digits=4)),
                ('worker_banned', models.BooleanField(default=False)),
                ('campaign', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Campaign')),
                ('worker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Worker')),
            ],
        ),
        migrations.CreateModel(
            name='Worker_Task',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('round', models.IntegerField()),
                ('timeout', models.BooleanField(default=True)),
                ('refused', models.BooleanField(default=False)),
                ('timestamp_in', models.DateTimeField(default=django.utils.timezone.now)),
                ('timestamp_out', models.DateTimeField()),
                ('answer', models.TextField(blank=True, null=True)),
                ('current_w_trustworthiness', models.DecimalField(decimal_places=2, max_digits=4)),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Task')),
                ('worker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Worker')),
            ],
        ),
        migrations.AddField(
            model_name='task_setup',
            name='t_task_setup',
            field=models.ManyToManyField(through='crowdsourcing.Task_Task_Setup', to='crowdsourcing.Task'),
        ),
        migrations.AddField(
            model_name='task',
            name='task_status',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crowdsourcing.Task_Status'),
        ),
        migrations.AddField(
            model_name='task',
            name='w_task',
            field=models.ManyToManyField(through='crowdsourcing.Worker_Task', to='crowdsourcing.Worker'),
        ),
        migrations.AddField(
            model_name='campaign',
            name='w_campaign',
            field=models.ManyToManyField(through='crowdsourcing.Worker_Campaign', to='crowdsourcing.Worker'),
        ),
        migrations.AlterUniqueTogether(
            name='worker_task',
            unique_together=set([('worker', 'task', 'round')]),
        ),
    ]
