# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-04-07 18:06
from __future__ import unicode_literals

import cerberus_ac.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AccessHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role_type', models.CharField(blank=True, max_length=255, verbose_name='Role type')),
                ('role_id', models.CharField(blank=True, max_length=255, verbose_name='Role ID')),
                ('response', models.NullBooleanField(default=None, verbose_name='Response')),
                ('response_type', models.CharField(choices=[('d', 'by default'), ('i', 'implicitly'), ('e', 'explicitly')], max_length=1, verbose_name='Response type')),
                ('access_type', models.CharField(max_length=255, verbose_name='Access')),
                ('resource_type', models.CharField(max_length=255, verbose_name='Resource type')),
                ('resource_id', models.CharField(blank=True, max_length=255, verbose_name='Resource ID')),
                ('datetime', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date and time')),
                ('conveyor_type', models.CharField(blank=True, max_length=255, verbose_name='Conveyor type')),
                ('conveyor_id', models.CharField(blank=True, max_length=255, verbose_name='Conveyor ID')),
            ],
            options={
                'verbose_name_plural': 'Access history',
                'verbose_name': 'Access history',
            },
        ),
        migrations.CreateModel(
            name='PrivilegeHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('privilege_id', models.PositiveIntegerField(null=True, verbose_name='Privilege reference ID')),
                ('action', models.CharField(choices=[('c', 'create'), ('u', 'update'), ('d', 'delete')], max_length=1, verbose_name='Action')),
                ('datetime', models.DateTimeField(auto_now_add=True, verbose_name='Date and time')),
                ('role_type', models.CharField(blank=True, max_length=255, verbose_name='Role type')),
                ('role_id', models.CharField(blank=True, max_length=255, verbose_name='Role ID')),
                ('authorized', models.NullBooleanField(default=None, verbose_name='Authorized')),
                ('access_type', models.CharField(blank=True, max_length=255, verbose_name='Access type')),
                ('resource_type', models.CharField(blank=True, max_length=255, verbose_name='Resource type')),
                ('resource_id', models.CharField(blank=True, max_length=255, verbose_name='Resource ID')),
            ],
            options={
                'verbose_name_plural': 'Privilege history',
                'verbose_name': 'Privilege history',
            },
        ),
        migrations.CreateModel(
            name='Role',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(max_length=255)),
                ('rid', models.CharField(blank=True, max_length=255)),
            ],
            options={
                'verbose_name_plural': 'Roles',
                'verbose_name': 'Role',
            },
            bases=(models.Model, cerberus_ac.models.RoleMixin),
        ),
        migrations.CreateModel(
            name='RoleHierarchy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role_type_a', models.CharField(max_length=255)),
                ('role_id_a', models.CharField(blank=True, max_length=255)),
                ('role_type_b', models.CharField(max_length=255)),
                ('role_id_b', models.CharField(blank=True, max_length=255)),
            ],
            options={
                'verbose_name_plural': 'Role hierarchy',
                'verbose_name': 'Role hierarchy',
            },
        ),
        migrations.CreateModel(
            name='RolePrivilege',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role_type', models.CharField(max_length=255, verbose_name='Role type')),
                ('role_id', models.CharField(blank=True, max_length=255, verbose_name='Role ID')),
                ('authorized', models.BooleanField(default=False, verbose_name='Authorized')),
                ('access_type', models.CharField(max_length=255, verbose_name='Access type')),
                ('resource_type', models.CharField(max_length=255, verbose_name='Resource type')),
                ('resource_id', models.CharField(blank=True, max_length=255, verbose_name='Resource ID')),
                ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='Created')),
                ('modification_date', models.DateTimeField(auto_now=True, verbose_name='Last modified')),
            ],
            options={
                'verbose_name_plural': 'Role privileges',
                'verbose_name': 'Role privilege',
            },
        ),
        migrations.AlterUniqueTogether(
            name='roleprivilege',
            unique_together=set([('role_type', 'role_id', 'access_type', 'resource_type', 'resource_id')]),
        ),
        migrations.AlterUniqueTogether(
            name='rolehierarchy',
            unique_together=set([('role_type_a', 'role_id_a', 'role_type_b', 'role_id_b')]),
        ),
        migrations.AlterUniqueTogether(
            name='role',
            unique_together=set([('type', 'rid')]),
        ),
        migrations.AddField(
            model_name='privilegehistory',
            name='reference',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='history', to='cerberus_ac.RolePrivilege', verbose_name='Privilege reference'),
        ),
        migrations.AddField(
            model_name='privilegehistory',
            name='user',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='privileges_changes', to=settings.AUTH_USER_MODEL, verbose_name='User'),
        ),
    ]
