# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-09-20 02:36
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import django_extensions.db.fields
import mtp.apps.broker_models_hooks.models
import mtp.apps.common.utils


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('media', '0006_fields_wording'),
        ('contenttypes', '0002_remove_content_type_name'),
        ('sync', '0003_add_index_on_update_synchornized'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Answer',
            fields=[
                ('id', django_extensions.db.fields.UUIDField(blank=True, editable=False, primary_key=True, serialize=False)),
                ('is_deleted', models.BooleanField(default=False)),
                ('update_locally', models.BooleanField(default=False)),
            ],
            bases=(models.Model, mtp.apps.broker_models_hooks.models.BrokerHookMixin),
        ),
        migrations.CreateModel(
            name='Choice',
            fields=[
                ('sort_order', models.IntegerField(blank=True, db_index=True)),
                ('id', django_extensions.db.fields.UUIDField(blank=True, editable=False, primary_key=True, serialize=False)),
                ('is_deleted', models.BooleanField(default=False)),
                ('update_locally', models.BooleanField(default=False)),
                ('label', models.CharField(max_length=280, verbose_name='Label')),
                ('is_valid', models.BooleanField(default=False, verbose_name='Is valid')),
                ('question_id', django_extensions.db.fields.UUIDField(blank=True, editable=False)),
                ('first_update', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_choice_by_first', to='sync.Update')),
                ('last_update', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_choice_by_last', to='sync.Update')),
                ('original_version', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='all_duplicates', to='questionnaires.Choice')),
                ('parent_version', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='direct_duplicates', to='questionnaires.Choice')),
                ('question_content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'ordering': ['sort_order'],
            },
        ),
        migrations.CreateModel(
            name='LivePolling',
            fields=[
                ('trainingactivity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='trainings.TrainingActivity')),
            ],
            options={
                'abstract': False,
            },
            bases=('trainings.trainingactivity',),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='LiveQuiz',
            fields=[
                ('trainingactivity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='trainings.TrainingActivity')),
                ('is_score_displayed', models.BooleanField(default=False, help_text='Display the score at the end of the questionnaire', verbose_name='Display score')),
            ],
            options={
                'abstract': False,
            },
            bases=('trainings.trainingactivity', models.Model),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='Polling',
            fields=[
                ('trainingactivity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='trainings.TrainingActivity')),
                ('are_questions_mandatory', models.BooleanField(default=False, help_text='Does the user have to answer all the questions ?', verbose_name='Questions are mandatory')),
            ],
            options={
                'abstract': False,
            },
            bases=('trainings.trainingactivity', models.Model),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='Question',
            fields=[
                ('sort_order', models.IntegerField(blank=True, db_index=True)),
                ('id', django_extensions.db.fields.UUIDField(blank=True, editable=False, primary_key=True, serialize=False)),
                ('is_deleted', models.BooleanField(default=False)),
                ('update_locally', models.BooleanField(default=False)),
                ('label', models.CharField(max_length=280, verbose_name='Label')),
                ('points', models.PositiveSmallIntegerField(default=1, verbose_name='Points')),
                ('questionnaire_id', django_extensions.db.fields.UUIDField(blank=True, editable=False)),
            ],
            options={
                'ordering': ['sort_order'],
            },
        ),
        migrations.CreateModel(
            name='Quiz',
            fields=[
                ('trainingactivity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='trainings.TrainingActivity')),
                ('is_score_displayed', models.BooleanField(default=False, help_text='Display the score at the end of the questionnaire', verbose_name='Display score')),
                ('are_questions_mandatory', models.BooleanField(default=False, help_text='Does the user have to answer all the questions ?', verbose_name='Questions are mandatory')),
                ('is_questions_order_random', models.BooleanField(default=False, verbose_name='Randomize the questions order')),
            ],
            options={
                'abstract': False,
            },
            bases=('trainings.trainingactivity', models.Model),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='ChoicesAnswer',
            fields=[
                ('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='questionnaires.Answer')),
                ('choices', models.ManyToManyField(related_name='anwers', to='questionnaires.Choice')),
            ],
            options={
                'abstract': False,
            },
            bases=(mtp.apps.broker_models_hooks.models.BrokerHookM2MFromMixin, 'questionnaires.answer'),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('base_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='ChoicesQuestion',
            fields=[
                ('question_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='questionnaires.Question')),
                ('is_multiple_choices', models.BooleanField(default=False, help_text='The user can select multiple answers for this question', verbose_name='Multiple answers available')),
            ],
            options={
                'abstract': False,
            },
            bases=('questionnaires.question', models.Model),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='ImageChoicesQuestion',
            fields=[
                ('question_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='questionnaires.Question')),
                ('is_multiple_choices', models.BooleanField(default=False, help_text='The user can select multiple answers for this question', verbose_name='Multiple answers available')),
                ('image', models.ImageField(upload_to=mtp.apps.common.utils.upload_to_generator, verbose_name='Image')),
            ],
            options={
                'abstract': False,
            },
            bases=('questionnaires.question', models.Model),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='OpenAnswer',
            fields=[
                ('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='questionnaires.Answer')),
                ('content', models.TextField(blank=True, verbose_name='Content')),
            ],
            options={
                'abstract': False,
            },
            bases=('questionnaires.answer',),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('base_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.CreateModel(
            name='OpenQuestion',
            fields=[
                ('question_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='questionnaires.Question')),
            ],
            options={
                'abstract': False,
            },
            bases=('questionnaires.question',),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('dependency_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.AddField(
            model_name='question',
            name='first_update',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_question_by_first', to='sync.Update'),
        ),
        migrations.AddField(
            model_name='question',
            name='last_update',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_question_by_last', to='sync.Update'),
        ),
        migrations.AddField(
            model_name='question',
            name='original_version',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='all_duplicates', to='questionnaires.Question'),
        ),
        migrations.AddField(
            model_name='question',
            name='parent_version',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='direct_duplicates', to='questionnaires.Question'),
        ),
        migrations.AddField(
            model_name='question',
            name='polymorphic_ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_questionnaires.question_set+', to='contenttypes.ContentType'),
        ),
        migrations.AddField(
            model_name='question',
            name='questionnaire_content_type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'),
        ),
        migrations.AddField(
            model_name='answer',
            name='first_update',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_answer_by_first', to='sync.Update'),
        ),
        migrations.AddField(
            model_name='answer',
            name='last_update',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_answer_by_last', to='sync.Update'),
        ),
        migrations.AddField(
            model_name='answer',
            name='polymorphic_ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_questionnaires.answer_set+', to='contenttypes.ContentType'),
        ),
        migrations.AddField(
            model_name='answer',
            name='question',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='questionnaires.Question'),
        ),
        migrations.AddField(
            model_name='answer',
            name='session',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_answers', to='trainings.TrainingSession'),
        ),
        migrations.AddField(
            model_name='answer',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questionnaires_answers', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='question',
            unique_together=set([('questionnaire_id', 'questionnaire_content_type', 'sort_order')]),
        ),
        migrations.AlterUniqueTogether(
            name='choice',
            unique_together=set([('question_id', 'question_content_type', 'sort_order')]),
        ),
        migrations.AlterUniqueTogether(
            name='answer',
            unique_together=set([('user', 'session', 'question')]),
        ),
    ]
