# Generated by Django 5.2 on 2025-04-10 02:34

import access.fields
import access.models.tenancy
import django.db.models.deletion
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('access', '0004_organizationhistory_teamhistory'),
        ('auth', '0012_alter_user_first_name_max_length'),
        ('core', '0021_alter_ticketlinkeditem_item_type'),
    ]

    operations = [
        migrations.CreateModel(
            name='Entity',
            fields=[
                ('is_global', models.BooleanField(default=False, help_text='Is this a global object?', verbose_name='Global Object')),
                ('model_notes', models.TextField(blank=True, default=None, help_text='Tid bits of information', null=True, verbose_name='Notes')),
                ('id', models.AutoField(help_text='Primary key of the entry', primary_key=True, serialize=False, unique=True, verbose_name='ID')),
                ('entity_type', models.CharField(default='entity', help_text='Type this entity is', max_length=30, verbose_name='Entity Type')),
                ('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, help_text='Date and time of creation', verbose_name='Created')),
                ('modified', access.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, help_text='Date and time of last modification', verbose_name='Modified')),
                ('organization', models.ForeignKey(help_text='Organization this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.organization', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Organization')),
            ],
            options={
                'verbose_name': 'Entity',
                'verbose_name_plural': 'Entities',
                'ordering': ['created', 'modified', 'organization'],
            },
        ),
        migrations.CreateModel(
            name='Person',
            fields=[
                ('entity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='access.entity')),
                ('f_name', models.CharField(help_text='The persons first name', max_length=64, verbose_name='First Name')),
                ('m_name', models.CharField(blank=True, default=None, help_text='The persons middle name(s)', max_length=100, null=True, verbose_name='Middle Name(s)')),
                ('l_name', models.CharField(help_text='The persons Last name', max_length=64, verbose_name='Last Name')),
                ('dob', models.DateField(blank=True, default=None, help_text='The Persons Date of Birth (DOB)', null=True, verbose_name='DOB')),
            ],
            options={
                'verbose_name': 'Person',
                'verbose_name_plural': 'People',
                'ordering': ['l_name', 'm_name', 'f_name', 'dob'],
            },
            bases=('access.entity',),
        ),
        migrations.CreateModel(
            name='EntityHistory',
            fields=[
                ('modelhistory_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelhistory')),
                ('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='history', to='access.entity', verbose_name='Model')),
            ],
            options={
                'verbose_name': 'Entity History',
                'verbose_name_plural': 'Entity History',
                'db_table': 'access_entity_history',
                'ordering': ['-created'],
            },
            bases=('core.modelhistory',),
        ),
        migrations.CreateModel(
            name='EntityNotes',
            fields=[
                ('modelnotes_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelnotes')),
                ('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='access.entity', verbose_name='Model')),
            ],
            options={
                'verbose_name': 'Entity Note',
                'verbose_name_plural': 'Entity Notes',
                'db_table': 'access_entity_notes',
                'ordering': ['-created'],
            },
            bases=('core.modelnotes',),
        ),
        migrations.CreateModel(
            name='Role',
            fields=[
                ('model_notes', models.TextField(blank=True, default=None, help_text='Tid bits of information', null=True, verbose_name='Notes')),
                ('id', models.AutoField(help_text='Primary key of the entry', primary_key=True, serialize=False, unique=True, verbose_name='ID')),
                ('name', models.CharField(help_text='Name of this role', max_length=30, verbose_name='Name')),
                ('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, help_text='Date and time of creation', verbose_name='Created')),
                ('modified', access.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, help_text='Date and time of last modification', verbose_name='Modified')),
                ('organization', models.ForeignKey(help_text='Organization this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.organization', validators=[access.models.tenancy.TenancyObject.validatate_organization_exists], verbose_name='Organization')),
                ('permissions', models.ManyToManyField(blank=True, help_text='Permissions part of this role', related_name='roles', to='auth.permission', verbose_name='Permissions')),
            ],
            options={
                'verbose_name': 'Role',
                'verbose_name_plural': 'Roles',
                'ordering': ['organization', 'name'],
                'unique_together': {('organization', 'name')},
            },
        ),
        migrations.CreateModel(
            name='RoleHistory',
            fields=[
                ('modelhistory_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelhistory')),
                ('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='history', to='access.role', verbose_name='Model')),
            ],
            options={
                'verbose_name': 'Role History',
                'verbose_name_plural': 'Role History',
                'db_table': 'access_role_history',
                'ordering': ['-created'],
            },
            bases=('core.modelhistory',),
        ),
        migrations.CreateModel(
            name='RoleNotes',
            fields=[
                ('modelnotes_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.modelnotes')),
                ('model', models.ForeignKey(help_text='Model this note belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='access.role', verbose_name='Model')),
            ],
            options={
                'verbose_name': 'Role Note',
                'verbose_name_plural': 'Role Notes',
                'db_table': 'access_role_notes',
                'ordering': ['-created'],
            },
            bases=('core.modelnotes',),
        ),
        migrations.CreateModel(
            name='Contact',
            fields=[
                ('person_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='access.person')),
                ('directory', models.BooleanField(blank=True, default=True, help_text='Show contact details in directory', verbose_name='Show in Directory')),
                ('email', models.EmailField(help_text='E-mail address for this person', max_length=254, unique=True, verbose_name='E-Mail')),
            ],
            options={
                'verbose_name': 'Contact',
                'verbose_name_plural': 'Contacts',
                'ordering': ['email'],
            },
            bases=('access.person',),
        ),
    ]
