from django.conf import settings
from django.contrib.auth.models import Group
from django.db import migrations

from vbv_lernwelt.core.create_default_users import create_default_users
from vbv_lernwelt.core.models import User


def create_users(apps, schema_editor):
    default_password = 'ACEEs0DCmNaPxdoNV8vhccuCTRl9b'
    if settings.APP_ENVIRONMENT == 'development':
        default_password = None
    create_default_users(user_model=User, group_model=Group, default_password=default_password)


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0002_user_model"),
    ]

    operations = [
        migrations.RunPython(create_users),
    ]
