# Generated by Django 3.1.1 on 2021-02-02 03:41

import crams_contact.utils.validators
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('crams', '0008_load_crams_lookups'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Contact',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(blank=True, max_length=50, null=True)),
                ('given_name', models.CharField(blank=True, max_length=200, null=True)),
                ('surname', models.CharField(blank=True, max_length=200, null=True)),
                ('email', models.EmailField(db_index=True, max_length=254, unique=True)),
                ('phone', models.CharField(blank=True, max_length=50, null=True)),
                ('orcid', models.URLField(blank=True, null=True, validators=[crams_contact.utils.validators.validate_orcid], verbose_name='ORCID of contact')),
                ('scopusid', models.CharField(blank=True, max_length=50, null=True)),
                ('latest_contact', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='crams_contact.contact')),
            ],
        ),
        migrations.CreateModel(
            name='Organisation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('short_name', models.CharField(db_index=True, max_length=50)),
                ('ands_url', models.URLField(blank=True, null=True)),
                ('notification_email', models.EmailField(max_length=254)),
            ],
        ),
        migrations.CreateModel(
            name='Faculty',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('faculty_code', models.CharField(max_length=200)),
                ('name', models.CharField(max_length=200)),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='faculties', to='crams_contact.organisation')),
            ],
        ),
        migrations.CreateModel(
            name='EResearchContactIdentifier',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifier', models.CharField(max_length=254)),
                ('contact', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='archive_contact_ids', to='crams_contact.contact')),
                ('parent_erb_contact_id', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='crams_contact.eresearchcontactidentifier')),
                ('provision_details', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='eresearchcontactidentifier', to='crams.provisiondetails')),
                ('system', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='contact_identifiers', to='crams.eresearchbodyidkey')),
            ],
        ),
        migrations.CreateModel(
            name='Department',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('department_code', models.CharField(max_length=200)),
                ('name', models.CharField(max_length=200)),
                ('faculty', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='departments', to='crams_contact.faculty')),
            ],
        ),
        migrations.CreateModel(
            name='ContactDetail',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('B', 'Business'), ('P', 'Personal'), ('M', 'Mobile')], default='P', max_length=1)),
                ('restricted', models.BooleanField(default=False)),
                ('email', models.EmailField(blank=True, max_length=254, null=True)),
                ('phone', models.CharField(blank=True, max_length=50, null=True)),
                ('parent_contact', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='contact_details', to='crams_contact.contact')),
            ],
        ),
        migrations.AddField(
            model_name='contact',
            name='organisation',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='crams_contact.organisation'),
        ),
        migrations.CreateModel(
            name='CramsERBUserRoles',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_erb_admin', models.BooleanField(default=False)),
                ('is_tenant_manager', models.BooleanField(default=False)),
                ('end_date_ts', models.DateTimeField(blank=True, null=True)),
                ('admin_erb_systems', models.ManyToManyField(related_name='admin_contacts', to='crams.EResearchBodySystem')),
                ('approver_erb_systems', models.ManyToManyField(related_name='approver_contacts', to='crams.EResearchBodySystem')),
                ('contact', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='user_roles', to='crams_contact.contact')),
                ('delegates', models.ManyToManyField(related_name='delegate_contacts', to='crams.EResearchBodyDelegate')),
                ('providers', models.ManyToManyField(related_name='provider_contacts', to='crams.Provider')),
                ('role_erb', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='contacts', to='crams.eresearchbody')),
            ],
            options={
                'unique_together': {('contact', 'role_erb', 'end_date_ts')},
            },
        ),
        migrations.CreateModel(
            name='ContactRole',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('project_leader', models.BooleanField(default=False)),
                ('read_only', models.BooleanField(default=False)),
                ('support_notification', models.BooleanField(default=False)),
                ('e_research_body', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='contact_roles', to='crams.eresearchbody')),
            ],
            options={
                'unique_together': {('name', 'e_research_body')},
            },
        ),
        migrations.CreateModel(
            name='ContactLabel',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('creation_ts', models.DateTimeField(auto_now_add=True)),
                ('last_modified_ts', models.DateTimeField(auto_now=True)),
                ('label_name', models.CharField(max_length=255)),
                ('active', models.BooleanField(default=True)),
                ('contact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='labels', to='crams_contact.contact')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='contactlabel_created_by', to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='contactlabel_updated_by', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('label_name', 'contact')},
            },
        ),
    ]
