# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-01 23:15

import autoslug.fields
import common.utils
import datetime
from django.conf import settings
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
import open_humans.storage
import private_sharing.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('open_humans', '0003_auto_20151223_1827'),
        ('oauth2_provider', '__first__'),
        ('open_humans', '0004_member_badges'),
    ]

    operations = [
        migrations.CreateModel(
            name='DataRequestProject',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_study', models.BooleanField(choices=[(True, 'Study'), (False, 'Activity')], help_text='A "study" is doing human subjects research and must have Institutional Review Board approval or equivalent ethics board oversight. Activities can be anything else, e.g. data visualizations.', verbose_name='Is this project a study or an activity?')),
                ('name', models.CharField(max_length=100, verbose_name='Project name')),
                ('leader', models.CharField(max_length=100, verbose_name='Leader(s) or principal investigator(s)')),
                ('organization', models.CharField(max_length=100, verbose_name='Organization or institution')),
                ('contact_email', models.EmailField(max_length=254, verbose_name='Contact email for your project')),
                ('info_url', models.URLField(verbose_name='URL for general information about your project')),
                ('short_description', models.CharField(max_length=140, verbose_name='A short description')),
                ('long_description', models.TextField(max_length=1000, verbose_name='A long description')),
                ('active', models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], default=True, help_text='"Active" status is required to perform authorization\nprocesses, including during drafting stage. If a project is not active,\nit won\'t show up in listings, and new data sharing authorizations cannot occur.\nProjects which are "active" but not approved may have some information shared\nin an "In Development" section, so Open Humans members can see potential\nupcoming studies.')),
                ('badge_image', models.ImageField(blank=True, help_text="A badge that will be displayed on the user's profile once they've connected your project.", max_length=1024, storage=open_humans.storage.PublicStorage(), upload_to=private_sharing.models.badge_upload_path)),
                ('request_sources_access', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), help_text='List of sources this project is requesting access to on Open Humans.', size=None, verbose_name="Data sources you're requesting access to")),
                ('request_message_permission', models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], help_text='Permission to send messages to the member. This does not grant access to their email address.', verbose_name='Are you requesting permission to message users?')),
                ('request_username_access', models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], help_text="Access to the member's username. This implicitly enables access to anything the user is publicly sharing on Open Humans. Note that this is potentially sensitive and/or identifying.", verbose_name='Are you requesting Open Humans usernames?')),
                ('approved', models.BooleanField(default=False)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('last_updated', models.DateTimeField(auto_now=True)),
                ('api_access_secret', models.CharField(max_length=64)),
            ],
            options={
                'verbose_name_plural': 'Data request activities',
            },
        ),
        migrations.CreateModel(
            name='DataRequestProjectMember',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_id_code', models.CharField(max_length=16)),
                ('message_permission', models.BooleanField()),
                ('username_shared', models.BooleanField()),
                ('sources_shared', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), size=None)),
                ('member', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='open_humans.Member')),
            ],
        ),
        migrations.CreateModel(
            name='OAuth2DataRequestProject',
            fields=[
                ('datarequestproject_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='private_sharing.DataRequestProject')),
                ('enrollment_url', models.URLField(help_text="The URL we direct members to if they're interested in sharing data with your project.", verbose_name='Enrollment URL')),
                ('redirect_url', models.CharField(help_text='The return URL for our "authorization code" OAuth2 grant\n        process. You can <a target="_blank" href="">read more about OAuth2\n        "authorization code" transactions here</a>.', max_length=256, verbose_name='Redirect URL')),
                ('application', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
            ],
            options={
                'verbose_name': 'OAuth2 data request project',
            },
            bases=('private_sharing.datarequestproject',),
        ),
        migrations.CreateModel(
            name='OnSiteDataRequestProject',
            fields=[
                ('datarequestproject_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='private_sharing.DataRequestProject')),
                ('consent_text', models.TextField(help_text='The "informed consent" text that describes your project to Open Humans members.')),
                ('post_sharing_url', models.URLField(blank=True, help_text='If provided, after authorizing sharing the\nmember will be taken to this URL. If this URL includes "PROJECT_MEMBER_ID"\nwithin it, we will replace that with the member\'s project-specific\nproject_member_id. This allows you to direct them to an external survey you\noperate (e.g. using Google Forms) where a pre-filled project_member_id field\nallows you to connect those responses to corresponding data in Open Humans.', verbose_name='Post-sharing URL')),
            ],
            options={
                'verbose_name': 'On-site data request project',
            },
            bases=('private_sharing.datarequestproject',),
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='project',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_members', to='private_sharing.DataRequestProject'),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='coordinator',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='open_humans.Member'),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='long_description',
            field=models.TextField(max_length=1000, verbose_name='A long description (1000 characters max)'),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='short_description',
            field=models.CharField(max_length=140, verbose_name='A short description (140 characters max)'),
        ),
        migrations.AlterField(
            model_name='datarequestprojectmember',
            name='member',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='open_humans.Member'),
        ),
        migrations.RenameField(
            model_name='datarequestprojectmember',
            old_name='user_id_code',
            new_name='project_member_id',
        ),
        migrations.AlterField(
            model_name='datarequestprojectmember',
            name='project_member_id',
            field=models.CharField(max_length=16, unique=True),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='request_sources_access',
            field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), default=list, help_text='List of sources this project is requesting access to on Open Humans.', size=None, verbose_name="Data sources you're requesting access to"),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='active',
            field=models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], default=True, help_text='"Active" status is required to perform authorization\nprocesses, including during drafting stage. If a project is not active, it\nwon\'t show up in listings, and new data sharing authorizations cannot occur.\nProjects which are "active" but not approved may have some information shared\nin an "In Development" section, so Open Humans members can see potential\nupcoming studies.'),
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='created',
            field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2016, 3, 4, 5, 14, 50, 931889, tzinfo=utc)),
            preserve_default=False,
        ),
        migrations.AlterField(
            model_name='datarequestprojectmember',
            name='message_permission',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name='datarequestprojectmember',
            name='sources_shared',
            field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), default=list, size=None),
        ),
        migrations.AlterField(
            model_name='datarequestprojectmember',
            name='username_shared',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='slug',
            field=autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True),
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='revoked',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterModelOptions(
            name='datarequestproject',
            options={},
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='authorized',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='slug',
            field=autoslug.fields.AutoSlugField(always_update=True, editable=False, populate_from='name', unique=True),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='is_academic_or_nonprofit',
            field=models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], default=False, verbose_name='Is this institution or organization an academic institution or non-profit organization?'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='consent_text',
            field=models.TextField(blank=True),
        ),
        migrations.RemoveField(
            model_name='datarequestproject',
            name='api_access_secret',
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='master_access_token',
            field=models.CharField(default=common.utils.generate_id, max_length=64),
        ),
        migrations.AddField(
            model_name='datarequestprojectmember',
            name='joined',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='request_sources_access',
            field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100), blank=True, default=list, help_text='List of sources this project is requesting access to on Open Humans.', size=None, verbose_name="Data sources you're requesting access to"),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='organization',
            field=models.CharField(blank=True, max_length=100, verbose_name='Organization or institution'),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='returned_data_description',
            field=models.CharField(blank=True, help_text="Leave this blank if your project doesn't plan to add or return new data for your members.", max_length=140, verbose_name='Description of data you plan to upload to member  accounts (140 characters max)'),
        ),
        migrations.AlterField(
            model_name='datarequestproject',
            name='active',
            field=models.BooleanField(choices=[(True, 'Yes'), (False, 'No')], default=True, help_text='"Active" status is required to perform authorization\nprocesses, including during drafting stage. If a project is not active, it\nwon\'t show up in listings of activities that can be joined by participants, and\nnew data sharing authorizations cannot occur. Projects which are "active" but\nnot approved may have some information shared in an "In Development" section,\nso Open Humans members can see potential upcoming studies. Removing "active"\nstatus from a project will not remove any uploaded files from a project\nmember\'s profile.'),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='token_expiration_date',
            field=models.DateTimeField(default=private_sharing.models.now_plus_24_hours),
        ),
        migrations.AddField(
            model_name='datarequestproject',
            name='token_expiration_disabled',
            field=models.BooleanField(default=False),
        ),
    ]
