# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-03-03 16:41
from __future__ import unicode_literals

from django.db import migrations, models


def set_position(apps, schema_editor):
    Question = apps.get_model('pretixbase', 'Question')
    for q in Question.objects.all():
        for i, option in enumerate(q.options.all()):
            option.position = i
            option.save()


class Migration(migrations.Migration):

    dependencies = [
        ('pretixbase', '0083_auto_20180228_2102'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='questionoption',
            options={'ordering': ('position', 'id'), 'verbose_name': 'Question option', 'verbose_name_plural': 'Question options'},
        ),
        migrations.AddField(
            model_name='questionoption',
            name='position',
            field=models.IntegerField(default=0),
        ),
        migrations.AlterField(
            model_name='question',
            name='position',
            field=models.PositiveIntegerField(default=0, verbose_name='Position'),
        ),
        migrations.RunPython(
            set_position, 
            reverse_code=migrations.RunPython.noop,
        ),
    ]
