# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-02-01 23:33
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import smart_selects.db_fields


class Migration(migrations.Migration):

    dependencies = [
        ('main', '0035_emailoversizenotified_added'),
    ]

    operations = [
        migrations.CreateModel(
            name='Device',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('full_name', models.CharField(help_text='Give the full name of the device, eg. Simrad EK80 echo sounder.', max_length=255)),
                ('shortened_name', models.CharField(blank=True, help_text='A brief name by which the device is often known, eg. CTD.', max_length=255, null=True)),
                ('description', models.TextField(help_text='Give a full description of the device which includes some information about what it is used for, how it can be used and any specific details that separate it from similar instruments. If you have a URL about the device, please include it here.')),
                ('make', models.CharField(blank=True, max_length=255, null=True)),
                ('model', models.CharField(blank=True, max_length=255, null=True)),
                ('device_contact', models.ManyToManyField(help_text='Select the person / people who operated or was responsible for the instrument at some point during the voyage. This does not have to be every user of the instrument, but the main operator(s) for each leg.', to='main.Person')),
                ('leg_used', models.ManyToManyField(help_text='Select the leg(s) on which the device was used.', to='main.Leg')),
                ('main_device_type', models.ManyToManyField(blank=True, help_text='Select one or more options of available, from this list of controlled vocabulary devices. If there is nothing suitable, do not select anything. Note that there are some very specific devices and other more general categories, all of which should be selected if they are correct.', null=True, related_name='device_type', to='main.DeviceType')),
                ('platform', models.ManyToManyField(help_text='Select one or more platforms from which the device was operated or deployed.', related_name='possible_platform', to='main.Platform')),
                ('project', models.ManyToManyField(help_text='Select the projects which used the device or got samples / data from its deployments.', to='main.Project')),
            ],
        ),
        migrations.CreateModel(
            name='SpecificDevice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifying_mark', models.CharField(blank=True, help_text='If the device has an identifying number (prefereably a serial number), entering it here. This mark should distinguish from another instrument of the same type.', max_length=255, null=True)),
                ('type_of_identifying_mark', models.CharField(choices=[('serial number', 'serial number'), ('no identifying mark', 'no identifying mark'), ('mark handwritten on', 'mark handwritten on')], help_text='Choose the type of identifying mark on the instrument.', max_length=50)),
                ('possible_parent', models.ManyToManyField(blank=True, help_text='If the device is deployed by attaching it to another instrument, then it has a parent: enter this device here. Some devices may have more than one parent device, for example if the parent device breaks and is swapped.', null=True, to='main.SpecificDevice')),
                ('type_of_device', models.ForeignKey(help_text='Choose the type of device', on_delete=django.db.models.deletion.CASCADE, to='main.Device', verbose_name='Type')),
            ],
        ),
        migrations.AlterUniqueTogether(
            name='childdevice',
            unique_together=set([]),
        ),
        migrations.RemoveField(
            model_name='childdevice',
            name='possible_parents',
        ),
        migrations.RemoveField(
            model_name='childdevice',
            name='type_of_device',
        ),
        migrations.RemoveField(
            model_name='event',
            name='child_devices',
        ),
        migrations.DeleteModel(
            name='ChildDevice',
        ),
        migrations.AddField(
            model_name='event',
            name='specific_devices',
            field=smart_selects.db_fields.ChainedManyToManyField(blank=True, chained_field='linked_device', chained_model_field='possible_parents', help_text='Choose any devices that are attached to your instrument', to='main.SpecificDevice', verbose_name='Attached devices'),
        ),
        migrations.AlterUniqueTogether(
            name='specificdevice',
            unique_together=set([('type_of_device', 'identifying_mark')]),
        ),
    ]
