# Generated by Django 3.2.13 on 2024-10-25 10:09

import ddm.questionnaire.models
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('ddm', '0051_auto_20241025_1209'),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(
            state_operations=[
                migrations.CreateModel(
                    name='QuestionBase',
                    fields=[
                        ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                        ('question_type', models.CharField(choices=[('generic', 'Generic Question'), ('single_choice', 'Single Choice Question'), ('multi_choice', 'Multi Choice Question'), ('matrix', 'Matrix Question'), ('semantic_diff', 'Semantic Differential'), ('open', 'Open Question'), ('transition', 'Text Block')], default='generic', max_length=20)),
                        ('name', models.CharField(max_length=255)),
                        ('page', models.PositiveIntegerField(default=1, verbose_name='Page')),
                        ('index', models.PositiveIntegerField(default=1, verbose_name='Index')),
                        ('variable_name', models.SlugField(help_text='Will be used in the data export to identify responses to this question.', verbose_name='Variable name for storing response')),
                        ('text', models.TextField(blank=True, help_text='If a question is linked to a File Blueprint, data points from the donated data associated with the linked donation blueprint can be included in the question text. This data can be included as "{{ data }}" in the question text. It is possible to subset the data object (e.g., to include the last datapoint you can use {{ data.0 }} or include advanced rendering options included in the Django templating engine. For a more comprehensive overview and examples see the documentation. Additionally, information directly related to the participant can be included in the question text. This information can be referenced as "{{ participant }}".', null=True)),
                        ('required', models.BooleanField(default=False)),
                        ('blueprint', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ddm.donationblueprint')),
                        ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_ddm_questionnaire.questionbase_set+', to='contenttypes.contenttype')),
                        ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ddm.donationproject')),
                    ],
                    options={
                        'ordering': ['page', 'index'],
                    },
                ),
                migrations.CreateModel(
                    name='MatrixQuestion',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                        ('randomize_items', models.BooleanField(default=False)),
                    ],
                    options={
                        'abstract': False,
                    },
                    bases=(ddm.questionnaire.models.ScaleMixin, 'ddm_questionnaire.questionbase', models.Model),
                ),
                migrations.CreateModel(
                    name='MultiChoiceQuestion',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                        ('randomize_items', models.BooleanField(default=False)),
                    ],
                    options={
                        'abstract': False,
                    },
                    bases=('ddm_questionnaire.questionbase', models.Model),
                ),
                migrations.CreateModel(
                    name='OpenQuestion',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                        ('display', models.CharField(choices=[('small', 'Small'), ('large', 'Large')], default='large', help_text='"Small" displays a one-line textfield, "Large" a multiline textfield as input.', max_length=20)),
                    ],
                    options={
                        'abstract': False,
                        'base_manager_name': 'objects',
                    },
                    bases=('ddm_questionnaire.questionbase',),
                ),
                migrations.CreateModel(
                    name='SemanticDifferential',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                        ('randomize_items', models.BooleanField(default=False)),
                    ],
                    options={
                        'abstract': False,
                    },
                    bases=(ddm.questionnaire.models.ScaleMixin, 'ddm_questionnaire.questionbase', models.Model),
                ),
                migrations.CreateModel(
                    name='SingleChoiceQuestion',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                        ('randomize_items', models.BooleanField(default=False)),
                    ],
                    options={
                        'abstract': False,
                    },
                    bases=('ddm_questionnaire.questionbase', models.Model),
                ),
                migrations.CreateModel(
                    name='Transition',
                    fields=[
                        ('questionbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='ddm_questionnaire.questionbase')),
                    ],
                    options={
                        'abstract': False,
                        'base_manager_name': 'objects',
                    },
                    bases=('ddm_questionnaire.questionbase',),
                ),
                migrations.CreateModel(
                    name='ScalePoint',
                    fields=[
                        ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                        ('index', models.IntegerField()),
                        ('label', models.CharField(blank=True, max_length=100, null=True)),
                        ('value', models.IntegerField()),
                        ('add_border', models.BooleanField(default=False)),
                        ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ddm_questionnaire.questionbase')),
                    ],
                    options={
                        'ordering': ['index'],
                    },
                ),
                migrations.CreateModel(
                    name='QuestionnaireResponse',
                    fields=[
                        ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                        ('time_submitted', models.DateTimeField(default=django.utils.timezone.now)),
                        ('data', models.BinaryField()),
                        ('participant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ddm.participant')),
                        ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ddm.donationproject')),
                    ],
                    options={
                        'abstract': False,
                    },
                ),
                migrations.CreateModel(
                    name='QuestionItem',
                    fields=[
                        ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                        ('label', models.CharField(blank=True, max_length=255, null=True)),
                        ('label_alt', models.CharField(blank=True, max_length=255, null=True)),
                        ('index', models.IntegerField()),
                        ('value', models.IntegerField()),
                        ('randomize', models.BooleanField(default=False)),
                        ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ddm_questionnaire.questionbase')),
                    ],
                    options={
                        'ordering': ['index'],
                    },
                ),
                migrations.AddConstraint(
                    model_name='scalepoint',
                    constraint=models.UniqueConstraint(fields=('index', 'question'), name='unique_index_per_question'),
                ),
                migrations.AddConstraint(
                    model_name='questionitem',
                    constraint=models.UniqueConstraint(fields=('index', 'question'), name='unique_item_index_per_question'),
                ),
                migrations.AddConstraint(
                    model_name='questionitem',
                    constraint=models.UniqueConstraint(fields=('value', 'question'), name='unique_item_value_per_question'),
                ),
                migrations.AddConstraint(
                    model_name='questionbase',
                    constraint=models.UniqueConstraint(fields=('variable_name', 'project'), name='unique_varname_per_project'),
                ),
            ],
            # Table already exists. See ddm/migrations/0051_auto_20241025_1209.py
            database_operations=[],
        )
    ]
