# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-04-05 19:55
from __future__ import unicode_literals

from django.db import migrations
from django.contrib.auth.models import User


STAFF_PASSWORD = 'staff'
SUPERUSER_PASSWORD = 'superuser'


class Migration(migrations.Migration):
    """A data migration to create initial staff / superusers
    """

    def create_initial_users(apps, schema_editor):

        staff_user = User.objects.create_user(
            username='staff', password=STAFF_PASSWORD, is_staff=True
        )

        superuser = User.objects.create_user(
            username='superuser',
            password=SUPERUSER_PASSWORD,
            is_superuser=True,
            is_staff=True,
        )

        print(
            "\n Created initial Staff user with login "
            "credentials: '{0} / {1}'".format(
                staff_user.username, STAFF_PASSWORD
            )
        )

        print(
            "\n Created initial Superuser user with login "
            "credentials: '{0} / {1}'".format(
                superuser.username, SUPERUSER_PASSWORD
            )
        )

    def remove_initial_users(apps, schema_editor):
        # there's no point to remove Users:
        pass

    dependencies = [
        ('medeina', '0004_auto_20180405_1954'),
    ]

    operations = [
        migrations.RunPython(
            create_initial_users,
            remove_initial_users
        ),
    ]
