# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2018-01-17 17:50
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='Group',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='\u7ec4\u540d', max_length=64, unique=True, verbose_name='\u7ec4\u540d')),
                ('code', models.CharField(default='', help_text='\u7ec4code', max_length=64, verbose_name='\u7528\u6237\u7ec4\u4e2d\u6587\u540d')),
            ],
            options={
                'db_table': 'group',
                'verbose_name': '\u7528\u6237\u6743\u9650\u7ec4',
                'verbose_name_plural': '\u7528\u6237\u6743\u9650\u7ec4',
            },
        ),
        migrations.CreateModel(
            name='GroupURL',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('desc', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='\u5176\u4ed6\u4fe1\u606f')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.Group', verbose_name='\u7ec4')),
            ],
            options={
                'db_table': 'group_urls',
                'verbose_name': '\u7528\u6237\u6743\u9650\u7ec4\u5173\u7cfb',
                'verbose_name_plural': '\u7528\u6237\u6743\u9650\u7ec4\u5173\u7cfb',
            },
        ),
        migrations.CreateModel(
            name='URLSource',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('url', models.CharField(max_length=128, verbose_name='url')),
                ('action', models.CharField(max_length=16, verbose_name='\u8bf7\u6c42\u65b9\u6cd5')),
                ('description', models.CharField(blank=True, default='', max_length=256, null=True, verbose_name='\u63cf\u8ff0\u4fe1\u606f')),
                ('parameters', models.CharField(blank=True, default='', max_length=256, null=True, verbose_name='\u53c2\u6570, \u9017\u53f7\u5206\u9694')),
            ],
            options={
                'ordering': ['id'],
                'verbose_name_plural': 'URL\u4fe1\u606f',
                'db_table': 'url_source',
                'verbose_name': 'URL\u4fe1\u606f',
            },
        ),
        migrations.CreateModel(
            name='UserGroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('desc', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='\u5176\u4ed6\u4fe1\u606f')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.Group', verbose_name='\u7ec4')),
            ],
            options={
                'db_table': 'user_groups',
                'verbose_name': '\u7528\u6237\u548c\u7ec4\u5173\u7cfb',
                'verbose_name_plural': '\u7528\u6237\u548c\u7ec4\u5173\u7cfb',
            },
        ),
        migrations.CreateModel(
            name='Userprofile',
            fields=[
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
                ('sex', models.IntegerField(choices=[(0, '\u5973\u6027'), (1, '\u7537\u6027'), (2, '\u672a\u586b\u5199')], default=2, help_text='sex')),
                ('desc', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='\u63cf\u8ff0')),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('groups', models.ManyToManyField(blank=True, through='url_permission.UserGroup', to='url_permission.Group', verbose_name='user groups')),
            ],
            options={
                'ordering': ['-create_time'],
                'db_table': 'user_profile',
                'verbose_name': '\u7528\u6237\u4fe1\u606f',
                'verbose_name_plural': '\u7528\u6237\u4fe1\u606f',
            },
        ),
        migrations.CreateModel(
            name='UserURL',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('desc', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='\u5176\u4ed6\u4fe1\u606f')),
                ('url', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.URLSource', verbose_name='URL')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.Userprofile', verbose_name='\u7528\u6237')),
            ],
            options={
                'db_table': 'user_urls',
                'verbose_name': '\u7528\u6237\u6743\u9650\u5173\u7cfb',
                'verbose_name_plural': '\u7528\u6237\u6743\u9650\u5173\u7cfb',
            },
        ),
        migrations.AddField(
            model_name='userprofile',
            name='user_permissions',
            field=models.ManyToManyField(blank=True, through='url_permission.UserURL', to='url_permission.URLSource', verbose_name='user permissions'),
        ),
        migrations.AddField(
            model_name='usergroup',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.Userprofile', verbose_name='\u7528\u6237'),
        ),
        migrations.AlterUniqueTogether(
            name='urlsource',
            unique_together=set([('url', 'action')]),
        ),
        migrations.AddField(
            model_name='groupurl',
            name='url',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='url_permission.URLSource', verbose_name='URL'),
        ),
        migrations.AddField(
            model_name='group',
            name='permissions',
            field=models.ManyToManyField(blank=True, through='url_permission.GroupURL', to='url_permission.URLSource', verbose_name='permissions'),
        ),
        migrations.AlterUniqueTogether(
            name='userurl',
            unique_together=set([('user', 'url')]),
        ),
        migrations.AlterUniqueTogether(
            name='usergroup',
            unique_together=set([('user', 'group')]),
        ),
        migrations.AlterUniqueTogether(
            name='groupurl',
            unique_together=set([('group', 'url')]),
        ),
    ]
