# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-08-01 08:00
from __future__ import unicode_literals

from django.db import migrations

from promort import settings as pms

import logging
logger = logging.getLogger('promort')


def create_odin_group(apps, schema_editor):
    logger.info('Creating default group for Odin users (if needed)')
    Group = apps.get_model('auth', 'Group')
    group_name = pms.DEFAULT_GROUPS['odin_members']['name']
    group, created = Group.objects.get_or_create(name=group_name)
    logger.info('Group "%s" --- Created %s', group.name, created)


class Migration(migrations.Migration):

    dependencies = [
        ('worklist_manager', '0002_auto_20170328_0652'),
    ]

    operations = [
        migrations.RunPython(create_odin_group),
    ]

create default group for ODIN users (if necessary)