# Generated by Django 2.2.1 on 2019-05-24 04:43

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


# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# core.migrations.0004_auto_20190418_2038
def create_ontask_user_info(apps, schema_editor):

    OnTaskUser = apps.get_model('ontask', 'OnTaskUser')
    User = apps.get_model('authtools', 'User')

    # Get all the existing ontask users first
    ousers_id = [x.user.id for x in OnTaskUser.objects.all()]

    # Get the regular users with not corresponding ontask user
    users = User.objects.exclude(id__in=ousers_id)

    # Remaining users in list need to have an OnTask element
    for user in users:
        ouser = OnTaskUser(user=user)
        ouser.save()


def reverse_migration(apps, schema_editor):
    pass


class Migration(migrations.Migration):

    replaces = [('ontask', '0001_core_initial'), ('ontask', '0002_auto_20190418_1539'), ('ontask', '0003_auto_20190418_1541'), ('ontask', '0004_auto_20190418_2038'), ('ontask', '0005_auto_20190419_0738')]

    dependencies = [
        ('ontask', '0017_auto_20190213_1623'),
        ('ontask', '0027_auto_20190418_1057'),
        ('authtoken', '0002_auto_20160226_1747'),
        ('authtools', '0003_auto_20160128_0912'),
        ('ontask', '0001_profiles_initial'),
        # ('ontask_oauth', '0004_auto_20181208_1306'),
        ('ontask', '0035_remove_scheduledaction_deleted'),
        ('admin', '0003_logentry_add_action_flag_choices'),
    ]

    operations = [
        migrations.CreateModel(
            name='OnTaskUser',
            fields=[
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='ontask_info', serialize=False, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.RunPython(create_ontask_user_info, reverse_code=reverse_migration),
        migrations.AlterModelOptions(
            name='ontaskuser',
            options={'verbose_name': 'ontaskuser', 'verbose_name_plural': 'ontaskusers'},
        ),
    ]

# Generated by Django 2.2.1 on 2019-05-24 04:43

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


# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# core.migrations.0004_auto_20190418_2038
def create_ontask_user_info(apps, schema_editor):

    OnTaskUser = apps.get_model('ontask', 'OnTaskUser')
    User = apps.get_model('authtools', 'User')

    # Get all the existing ontask users first
    ousers_id = [x.user.id for x in OnTaskUser.objects.all()]

    # Get the regular users with not corresponding ontask user
    users = User.objects.exclude(id__in=ousers_id)

    # Remaining users in list need to have an OnTask element
    for user in users:
        ouser = OnTaskUser(user=user)
        ouser.save()


def reverse_migration(apps, schema_editor):
    pass


class Migration(migrations.Migration):

    replaces = [('ontask', '0001_core_initial'), ('ontask', '0002_auto_20190418_1539'), ('ontask', '0003_auto_20190418_1541'), ('ontask', '0004_auto_20190418_2038'), ('ontask', '0005_auto_20190419_0738')]

    dependencies = [
        ('ontask', '0017_auto_20190213_1623'),
        ('ontask', '0027_auto_20190418_1057'),
        ('authtoken', '0002_auto_20160226_1747'),
        ('authtools', '0003_auto_20160128_0912'),
        ('ontask', '0001_profiles_initial'),
        # ('ontask_oauth', '0004_auto_20181208_1306'),
        ('ontask', '0035_remove_scheduledaction_deleted'),
        ('admin', '0003_logentry_add_action_flag_choices'),
    ]

    operations = [
        migrations.CreateModel(
            name='OnTaskUser',
            fields=[
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='ontask_info', serialize=False, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.RunPython(create_ontask_user_info, reverse_code=reverse_migration),
        migrations.AlterModelOptions(
            name='ontaskuser',
            options={'verbose_name': 'ontaskuser', 'verbose_name_plural': 'ontaskusers'},
        ),
    ]

# Generated by Django 2.2.1 on 2019-05-24 04:43 # Functions from the following migrations need manual copying. # Move them and any dependencies into this file, then update the # RunPython operations to refer to the local versions: # core.migrations.0004_auto_20190418_2038 # Get all the existing ontask users first # Get the regular users with not corresponding ontask user # Remaining users in list need to have an OnTask element # ('ontask_oauth', '0004_auto_20181208_1306'),