# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import datetime
from decimal import Decimal
from django.utils.timezone import utc
from django.conf import settings
import django.core.validators


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Crop',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('variety', models.CharField(help_text=b"Crop variety.  Use 'All' for no specific variety.", max_length=32, blank=True)),
                ('season_length_days', models.PositiveSmallIntegerField(verbose_name=b'Season Length (days)')),
                ('max_root_depth', models.PositiveSmallIntegerField(default=18, verbose_name=b'Maximum Root Depth (inches)')),
                ('cuser', models.ForeignKey(related_name='farms_crop_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_crop_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['name'],
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='CropEvent',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('order', models.PositiveSmallIntegerField(help_text=b'Events will be displayed in the order given by this (integer) value. Must be unique.')),
                ('duration', models.PositiveSmallIntegerField(help_text=b'length of this event (days)')),
                ('daily_water_use', models.DecimalField(help_text=b'Water absorbed by crop each day (inches)', max_digits=3, decimal_places=2)),
                ('max_temp_2in', models.DecimalField(decimal_places=0, max_digits=3, blank=True, help_text=b'Maximum allowed soil temperature at 2 inch depth (Farenheit)', null=True, verbose_name=b'Temp threshold at 2in')),
                ('key_event', models.BooleanField(default=False, help_text=b'Always display to user in crop event list')),
                ('irrigate_to_max', models.BooleanField(default=False, help_text=b'Irrigate to Max AWC then no more through harvest')),
                ('do_not_irrigate', models.BooleanField(default=False, help_text=b'Do not irrigate regardless of Average Water Content and Temperature')),
                ('irrigation_message', models.TextField(help_text=b'Message to display on Water Register', blank=True)),
                ('crop', models.ForeignKey(to='farms.Crop')),
                ('cuser', models.ForeignKey(related_name='farms_cropevent_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_cropevent_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['crop__name', 'order'],
                'verbose_name': 'Crop Event',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='CropSeason',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('season_start_date', models.DateField(default=datetime.datetime(2015, 5, 13, 4, 26, 22, 432961, tzinfo=utc), verbose_name=b'Season Start Date')),
                ('season_end_date', models.DateField(default=datetime.datetime(2015, 10, 14, 4, 26, 22, 432998, tzinfo=utc), verbose_name=b'Approximate Season End Date')),
                ('crop', models.ForeignKey(to='farms.Crop')),
                ('cuser', models.ForeignKey(related_name='farms_cropseason_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['season_start_date', 'crop'],
                'verbose_name': 'Crop Season',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='CropSeasonEvent',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('date', models.DateField(default=datetime.datetime(2015, 5, 13, 4, 26, 22, 434755, tzinfo=utc))),
                ('crop_event', models.ForeignKey(to='farms.CropEvent')),
                ('crop_season', models.ForeignKey(to='farms.CropSeason')),
                ('cuser', models.ForeignKey(related_name='farms_cropseasonevent_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['field', 'crop_event__order'],
                'verbose_name': 'Crop Season Event',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='Farm',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('address_1', models.CharField(max_length=50, verbose_name=b'address line 1', blank=True)),
                ('address_2', models.CharField(max_length=50, verbose_name=b'address line 2', blank=True)),
                ('city', models.CharField(max_length=32, blank=True)),
                ('county', models.CharField(max_length=32, blank=True)),
                ('state', models.CharField(max_length=2, blank=True)),
                ('zipcode', models.CharField(max_length=10, verbose_name=b'zip/postal code', blank=True)),
                ('country', models.CharField(default=b'United States', max_length=32, blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('gps_latitude', models.FloatField(null=True, verbose_name=b'GPS Latitude', blank=True)),
                ('gps_longitude', models.FloatField(null=True, verbose_name=b'GPS Longitude', blank=True)),
                ('cuser', models.ForeignKey(related_name='farms_farm_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('farmer', models.ForeignKey(related_name='farmers', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_farm_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
                ('users', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name=b'Authorized Users', blank=True)),
            ],
            options={
                'ordering': ['farmer'],
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='Field',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('acres', models.DecimalField(max_digits=5, decimal_places=2, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('irr_capacity', models.DecimalField(verbose_name=b'Irrigation Capacity (per 24 hours)', max_digits=3, decimal_places=2, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('cuser', models.ForeignKey(related_name='farms_field_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('farm', models.ForeignKey(to='farms.Farm')),
                ('muser', models.ForeignKey(related_name='farms_field_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['farm__farmer__username', 'farm__name', 'name'],
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='InvitedUser',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('email', models.EmailField(unique=True, max_length=75)),
                ('cuser', models.ForeignKey(related_name='farms_inviteduser_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('farms', models.ManyToManyField(to='farms.Farm')),
                ('muser', models.ForeignKey(related_name='farms_inviteduser_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='Probe',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('radio_id', models.CharField(max_length=10)),
                ('crop_season', models.ForeignKey(to='farms.CropSeason')),
                ('cuser', models.ForeignKey(related_name='farms_probe_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('field_list', models.ManyToManyField(to='farms.Field')),
                ('muser', models.ForeignKey(related_name='farms_probe_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='ProbeReading',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('farm_code', models.CharField(max_length=10, blank=True)),
                ('file_date', models.DateField(null=True, blank=True)),
                ('reading_datetime', models.DateTimeField()),
                ('probe_code', models.CharField(max_length=10, blank=True)),
                ('radio_id', models.CharField(max_length=10)),
                ('battery_voltage', models.DecimalField(null=True, max_digits=3, decimal_places=2, blank=True)),
                ('battery_percent', models.DecimalField(null=True, max_digits=5, decimal_places=2, blank=True)),
                ('soil_potential_8', models.DecimalField(max_digits=5, decimal_places=2)),
                ('soil_potential_16', models.DecimalField(max_digits=5, decimal_places=2)),
                ('soil_potential_24', models.DecimalField(max_digits=5, decimal_places=2)),
                ('circuit_board_temp', models.DecimalField(null=True, verbose_name=b'Circuit Board Temperature in Degrees Celcius', max_digits=5, decimal_places=2, blank=True)),
                ('thermocouple_1_temp', models.DecimalField(null=True, verbose_name=b'Thermocouple 1 Temperature in Degrees Celcius', max_digits=5, decimal_places=2, blank=True)),
                ('thermocouple_2_temp', models.DecimalField(null=True, verbose_name=b'Thermocouple 2 Temperature in Degrees Celcius', max_digits=5, decimal_places=2, blank=True)),
                ('minutes_awake', models.PositiveSmallIntegerField(null=True, blank=True)),
                ('source', models.CharField(default=b'User', max_length=6, choices=[(b'UGADB', b'UGA Database'), (b'User', b'User Entry')])),
                ('cuser', models.ForeignKey(related_name='farms_probereading_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_probereading_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Probe Reading',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='ProbeSync',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('datetime', models.DateTimeField()),
                ('success', models.BooleanField(default=False)),
                ('message', models.TextField()),
                ('nfiles', models.PositiveIntegerField(default=0)),
                ('nrecords', models.PositiveIntegerField(default=0)),
                ('filenames', models.TextField(blank=True)),
                ('cuser', models.ForeignKey(related_name='farms_probesync_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_probesync_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'get_latest_by': 'datetime',
                'verbose_name': 'Probe Data Synchronization',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='SoilType',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('name', models.CharField(max_length=32)),
                ('description', models.TextField(blank=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('max_available_water', models.DecimalField(null=True, max_digits=3, decimal_places=2, blank=True)),
                ('cuser', models.ForeignKey(related_name='farms_soiltype_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_soiltype_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['name'],
                'verbose_name': 'Soil Type',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='SoilTypeParameter',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('depth', models.PositiveSmallIntegerField(choices=[(8, b'8 inches'), (16, b'16 inches'), (24, b'24 inches')])),
                ('intercept', models.FloatField(verbose_name=b'Intercept Term (B0)')),
                ('slope', models.FloatField(verbose_name=b'Slope Term (B1)')),
                ('cuser', models.ForeignKey(related_name='farms_soiltypeparameter_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('muser', models.ForeignKey(related_name='farms_soiltypeparameter_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
                ('soil_type', models.ForeignKey(to='farms.SoilType')),
            ],
            options={
                'ordering': ['soil_type__name', 'depth'],
                'verbose_name': 'Soil Type Parameter',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='WaterHistory',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('comment', models.TextField(blank=True)),
                ('date', models.DateField()),
                ('rain', models.DecimalField(default=0.0, verbose_name=b'rainfall in inches', max_digits=4, decimal_places=2)),
                ('irrigation', models.DecimalField(default=0.0, verbose_name=b'irrigation in inches', max_digits=4, decimal_places=2)),
                ('available_water_content', models.DecimalField(default=0.0, null=True, max_digits=4, decimal_places=2, blank=True)),
                ('crop_season', models.ForeignKey(to='farms.CropSeason')),
                ('cuser', models.ForeignKey(related_name='farms_waterhistory_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('field_list', models.ManyToManyField(to='farms.Field')),
                ('muser', models.ForeignKey(related_name='farms_waterhistory_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Water History',
                'verbose_name_plural': 'Water Histories',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='WaterRegister',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('cdate', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
                ('mdate', models.DateTimeField(auto_now=True, verbose_name=b'last modification date')),
                ('date', models.DateField()),
                ('crop_stage', models.CharField(max_length=32)),
                ('daily_water_use', models.DecimalField(max_digits=3, decimal_places=2)),
                ('max_temp_2in', models.DecimalField(decimal_places=0, max_digits=3, blank=True, help_text=b'Maximum allowed soil tempoerature at 2 inch depth (Farenheit)', null=True, verbose_name=b'Temp threshold at 2in')),
                ('do_not_irrigate', models.BooleanField(default=False, help_text=b'Do not irrigate regardless of Average Water Content and Temperature')),
                ('message', models.TextField(blank=True)),
                ('irrigate_to_max', models.BooleanField(default=False)),
                ('rain', models.DecimalField(max_digits=3, decimal_places=2, blank=True)),
                ('irrigation', models.DecimalField(max_digits=3, decimal_places=2, blank=True)),
                ('average_water_content', models.DecimalField(max_digits=4, decimal_places=2)),
                ('max_observed_temp_2in', models.DecimalField(null=True, max_digits=4, decimal_places=1, blank=True)),
                ('computed_from_probes', models.BooleanField(default=False)),
                ('irrigate_flag', models.BooleanField(default=False)),
                ('too_hot_flag', models.BooleanField(default=False)),
                ('check_sensors_flag', models.BooleanField(default=False)),
                ('dry_down_flag', models.BooleanField(default=False)),
                ('irrigate_to_max_seen', models.BooleanField(default=False)),
                ('irrigate_to_max_achieved', models.BooleanField(default=False)),
                ('days_to_irrigation', models.SmallIntegerField(default=-1)),
                ('crop_season', models.ForeignKey(to='farms.CropSeason')),
                ('cuser', models.ForeignKey(related_name='farms_waterregister_cusers', verbose_name=b'creator', to=settings.AUTH_USER_MODEL)),
                ('field', models.ForeignKey(to='farms.Field')),
                ('muser', models.ForeignKey(related_name='farms_waterregister_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('crop_season', 'field', 'date'),
                'verbose_name': 'Water Register',
            },
            bases=(models.Model,),
        ),
        migrations.AlterUniqueTogether(
            name='waterregister',
            unique_together=set([('crop_season', 'field', 'date')]),
        ),
        migrations.AlterUniqueTogether(
            name='probereading',
            unique_together=set([('radio_id', 'reading_datetime')]),
        ),
        migrations.AlterUniqueTogether(
            name='probe',
            unique_together=set([('crop_season', 'radio_id')]),
        ),
        migrations.AddField(
            model_name='field',
            name='soil_type',
            field=models.ForeignKey(to='farms.SoilType'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='cropseasonevent',
            name='field',
            field=models.ForeignKey(to='farms.Field'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='cropseasonevent',
            name='muser',
            field=models.ForeignKey(related_name='farms_cropseasonevent_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL),
            preserve_default=True,
        ),
        migrations.AlterUniqueTogether(
            name='cropseasonevent',
            unique_together=set([('crop_season', 'field', 'crop_event')]),
        ),
        migrations.AddField(
            model_name='cropseason',
            name='field_list',
            field=models.ManyToManyField(to='farms.Field'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='cropseason',
            name='muser',
            field=models.ForeignKey(related_name='farms_cropseason_musers', verbose_name=b'last modifcation user', to=settings.AUTH_USER_MODEL),
            preserve_default=True,
        ),
        migrations.AlterUniqueTogether(
            name='cropevent',
            unique_together=set([('crop', 'order')]),
        ),
    ]
