# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-22 21:44
from __future__ import unicode_literals

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

import archive_api.models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
       # ('auth', '0008_alter_user_username_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='Author',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.PositiveIntegerField(default=0)),
            ],
            options={
                'ordering': ('dataset', 'order'),
            },
        ),
        migrations.CreateModel(
            name='DataSet',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ngt_id', models.IntegerField()),
                ('description', models.TextField(blank=True, null=True)),
                ('version', models.CharField(default='0.0', max_length=15)),
                ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Submitted'), (2, 'Approved')], default=0)),
                ('status_comment', models.TextField(blank=True, null=True)),
                ('name', models.CharField(blank=True, max_length=150, null=True)),
                ('doi', models.TextField(blank=True, null=True)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('qaqc_status',
                 models.IntegerField(blank=True, choices=[(0, 'None'), (1, 'Preliminary QA-QC'), (2, 'Full QA-QC')],
                                     null=True)),
                ('qaqc_method_description', models.TextField(blank=True, null=True)),
                ('ngee_tropics_resources', models.BooleanField(default=False)),
                ('funding_organizations', models.TextField(blank=True, null=True)),
                ('doe_funding_contract_numbers', models.CharField(blank=True, max_length=100, null=True)),
                ('acknowledgement', models.TextField(blank=True, null=True)),
                ('reference', models.TextField(blank=True, null=True)),
                ('additional_reference_information', models.TextField(blank=True, null=True)),
                ('originating_institution', models.TextField(blank=True, null=True)),
                ('access_level',
                 models.IntegerField(choices=[(0, 'Private'), (1, 'NGEE Tropics'), (2, 'Public')], default=0)),
                ('additional_access_information', models.TextField(blank=True, null=True)),
                ('submission_date', models.DateField(blank=True, null=True)),
                ('created_date', models.DateTimeField(auto_now_add=True)),
                ('modified_date', models.DateTimeField(auto_now=True)),
                ('cdiac_import', models.BooleanField(default=False)),
                ('archive',
                 models.FileField(null=True, storage=archive_api.models.DatasetArchiveStorage(),
                                                        upload_to=archive_api.models.get_upload_path)),
            ],
            options={
                'permissions': (('approve_submitted_dataset', "Can approve a 'submitted' dataset"),
                                ("edit_own_draft_dataset", "Can edit own 'draft' dataset"),
                                ("edit_all_submitted_dataset", "Can edit any 'submitted' dataset"),
                                ("edit_all_draft_dataset", "Can edit any 'draft' dataset"),
                                ('unsubmit_submitted_dataset', "Can unsubmit a 'submitted' dataset"),
                                ('unapprove_approved_dataset', "Can unapprove a 'approved' dataset"),
                                ('view_all_datasets', 'Can view all datasets'),
                                ('view_ngeet_approved_datasets', 'Can view all approved NGEE Tropics datasets'),
                                ("upload_large_file_dataset", "Can upload a large file to a dataset")),
            },
        ),
        migrations.CreateModel(
            name='DataSetDownloadLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('dataset_status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Submitted'), (2, 'Approved')])),
                ('request_url', models.CharField(max_length=256)),
                ('datetime', models.DateTimeField(auto_now_add=True)),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                (
                'dataset', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='archive_api.DataSet')),
            ],
        ),
        migrations.CreateModel(
            name='MeasurementVariable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Person',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('first_name', models.CharField(max_length=50)),
                ('last_name', models.CharField(blank=True, max_length=50)),
                ('email', models.EmailField(blank=True, max_length=254)),
                ('institution_affiliation', models.CharField(blank=True, max_length=100)),
                ('user_role', models.IntegerField(blank=True, choices=[(0, 'Team'), (1, 'Collaborator')], null=True)),
            ],
            options={
                'ordering': ('last_name', 'first_name'),
            },
        ),
        migrations.CreateModel(
            name='Plot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plot_id', models.CharField(max_length=30, unique=True)),
                ('name', models.CharField(max_length=150, unique=True)),
                ('description', models.TextField()),
                ('size', models.CharField(blank=True, max_length=100, null=True)),
                ('location_elevation', models.CharField(blank=True, max_length=30, null=True)),
                ('location_kmz_url', models.URLField(blank=True, null=True)),
                ('submission_date', models.DateField(blank=True, null=True)),
                ('pi', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING,
                                         to='archive_api.Person')),
            ],
        ),
        migrations.CreateModel(
            name='Site',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('site_id', models.CharField(max_length=30, unique=True)),
                ('name', models.CharField(max_length=300, unique=True)),
                ('description', models.TextField()),
                ('country', models.CharField(blank=True, max_length=100)),
                ('state_province', models.CharField(blank=True, max_length=100)),
                ('utc_offset', models.IntegerField(blank=True, null=True)),
                ('location_latitude', models.FloatField(blank=True, null=True)),
                ('location_longitude', models.FloatField(blank=True, null=True)),
                ('location_elevation', models.CharField(blank=True, max_length=30)),
                ('location_map_url', models.URLField(blank=True, null=True)),
                ('location_bounding_box_ul_latitude', models.FloatField(blank=True, null=True)),
                ('location_bounding_box_ul_longitude', models.FloatField(blank=True, null=True)),
                ('location_bounding_box_lr_latitude', models.FloatField(blank=True, null=True)),
                ('location_bounding_box_lr_longitude', models.FloatField(blank=True, null=True)),
                ('site_urls', models.TextField(blank=True, null=True)),
                ('submission_date', models.DateField(blank=True, null=True)),
                ('contacts', models.ManyToManyField(to='archive_api.Person')),
                ('pis', models.ManyToManyField(related_name='_site_pis_+', to='archive_api.Person')),
                ('submission', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='+',
                                                 to='archive_api.Person')),
            ],
        ),
        migrations.CreateModel(
            name='NGTUser',
            fields=[
            ],
            options={
                'proxy': True,
            },
            bases=('auth.user',),
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.AddField(
            model_name='plot',
            name='site',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='archive_api.Site'),
        ),
        migrations.AddField(
            model_name='plot',
            name='submission',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='+',
                                    to='archive_api.Person'),
        ),
        migrations.AddField(
            model_name='person',
            name='user',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE,
                                       to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='datasetdownloadlog',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='dataset',
            name='authors',
            field=models.ManyToManyField(blank=True, related_name='_dataset_authors_+', through='archive_api.Author',
                                         to='archive_api.Person'),
        ),
        migrations.AddField(
            model_name='dataset',
            name='cdiac_submission_contact',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING,
                                    related_name='+', to='archive_api.Person'),
        ),
        migrations.AddField(
            model_name='dataset',
            name='contact',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING,
                                    to='archive_api.Person'),
        ),
        migrations.AddField(
            model_name='dataset',
            name='created_by',
            field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='+',
                                    to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='dataset',
            name='modified_by',
            field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='+',
                                    to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='dataset',
            name='plots',
            field=models.ManyToManyField(blank=True, to='archive_api.Plot'),
        ),
        migrations.AddField(
            model_name='dataset',
            name='sites',
            field=models.ManyToManyField(blank=True, to='archive_api.Site'),
        ),
        migrations.AddField(
            model_name='dataset',
            name='variables',
            field=models.ManyToManyField(blank=True, to='archive_api.MeasurementVariable'),
        ),
        migrations.AddField(
            model_name='author',
            name='author',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='archive_api.Person'),
        ),
        migrations.AddField(
            model_name='author',
            name='dataset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='archive_api.DataSet'),
        ),
        migrations.AlterUniqueTogether(
            name='person',
            unique_together=set([('first_name', 'last_name', 'institution_affiliation', 'email')]),
        ),
        migrations.AlterUniqueTogether(
            name='dataset',
            unique_together=set([('ngt_id', 'version')]),
        ),
        migrations.AlterUniqueTogether(
            name='author',
            unique_together=set([('dataset', 'order', 'author')]),
        ),
    ]
