# Generated by Django 3.2.7 on 2021-09-12 19:20

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Firm',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=150, unique=True, verbose_name='Название компании')),
                ('address', models.CharField(max_length=150, verbose_name='Адрес')),
                ('description', models.TextField(verbose_name='Описание')),
            ],
            options={
                'verbose_name': 'Компания',
                'verbose_name_plural': 'Компании',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Phone',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('phone_number', phone_field.models.PhoneField(help_text='Телефонный номер', max_length=31, verbose_name='Телефонный номер')),
                ('type', models.CharField(choices=[('Office phone', 'Рабочий'), ('Personal phone', 'Личный'), ('Fax phone', 'Факс')], max_length=15, verbose_name='Тип номера')),
            ],
            options={
                'verbose_name': 'Телефонный номер',
                'verbose_name_plural': 'Телефонные номера',
            },
        ),
        migrations.CreateModel(
            name='Profession',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('profession', models.CharField(max_length=150, unique=True, verbose_name='Должность')),
            ],
            options={
                'verbose_name': 'Профессия',
                'verbose_name_plural': 'Профессии',
                'ordering': ['profession'],
            },
        ),
        migrations.CreateModel(
            name='UserFirmRelation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('firm', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='corporations.firm', verbose_name='Компания')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')),
            ],
            options={
                'verbose_name': 'Пользователь с правами администратора',
                'verbose_name_plural': 'Пользователи с правами администратора',
                'ordering': ['firm'],
            },
        ),
        migrations.AddField(
            model_name='firm',
            name='access_edit',
            field=models.ManyToManyField(through='corporations.UserFirmRelation', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='firm',
            name='creator',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='creator', to=settings.AUTH_USER_MODEL, verbose_name='Создатель компании в базе'),
        ),
        migrations.CreateModel(
            name='Employee',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(max_length=50, verbose_name='Имя')),
                ('last_name', models.CharField(max_length=50, verbose_name='Фамилия')),
                ('middle_name', models.CharField(max_length=50, verbose_name='Отчество')),
                ('firm', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='employees', to='corporations.firm', verbose_name='Компания')),
                ('phone', models.ManyToManyField(related_name='employees', to='corporations.Phone', verbose_name='Телефоны')),
                ('profession', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='corporations.profession', verbose_name='Должность')),
            ],
            options={
                'verbose_name': 'Сотрудник',
                'verbose_name_plural': 'Сотрудники',
                'ordering': ['firm'],
            },
        ),
        migrations.AddConstraint(
            model_name='userfirmrelation',
            constraint=models.UniqueConstraint(fields=('user', 'firm'), name='unique_userfirm'),
        ),
    ]
