From a541a6f301ca7aae4b3f40c11f07ef073fa72e35 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 15 Jun 2016 15:12:34 -0700 Subject: [PATCH] SQUASHING --- .../migrations/0001_initial.py | 139 +++++++++++---- ...5_DATA_initial.py => 0002_DATA_initial.py} | 19 +- .../0002_collection_display_name.py | 20 --- .../migrations/0003_collections_ordering.py | 18 -- .../migrations/0004_collections_ordering.py | 18 -- .../migrations/0006_set_labels.py | 69 -------- ccdb/experiments/migrations/0001_initial.py | 167 ++++++++++++++++-- ...9_DATA_initial.py => 0002_DATA_initial.py} | 30 +++- .../migrations/0002_treatment_type.py | 36 ---- ccdb/experiments/migrations/0003_treatment.py | 29 --- .../migrations/0004_treatment_replicate.py | 31 ---- .../migrations/0005_alivedeadcount.py | 26 --- .../migrations/0006_experiment_collections.py | 20 --- .../0007_treatment_replicates_display.py | 24 --- .../migrations/0008_treatment_display_name.py | 20 --- .../0010_DATA_collections_experiments.py | 38 ---- .../experiments/migrations/0011_set_labels.py | 74 -------- ccdb/locations/migrations/0001_initial.py | 90 ++++++---- ...4_DATA_initial.py => 0002_DATA_initial.py} | 3 +- .../migrations/0002_remove_site_fk_dupes.py | 23 --- .../0003_study_location_code_req.py | 19 -- ccdb/locations/migrations/0005_set_labels.py | 29 --- ccdb/misc/migrations/0001_initial.py | 78 ++++---- ccdb/misc/migrations/0002_DATA_initial.py | 1 + ccdb/misc/migrations/0003_set_labels.py | 34 ---- ccdb/processing/migrations/0001_initial.py | 67 ++++--- .../migrations/0002_DATA_initial.py | 1 + ccdb/processing/migrations/0003_set_labels.py | 39 ---- ccdb/projects/migrations/0001_initial.py | 77 ++++++++ .../migrations/0001_initial_project.py | 33 ---- ...5_DATA_initial.py => 0002_DATA_initial.py} | 3 +- .../projects/migrations/0002_initial_grant.py | 31 ---- .../migrations/0003_grant_projects.py | 19 -- .../migrations/0004_initial_grantreport.py | 35 ---- ccdb/projects/migrations/0006_set_labels.py | 19 -- ccdb/species/migrations/0001_initial.py | 61 ++++++- ...4_DATA_initial.py => 0002_DATA_initial.py} | 4 +- ccdb/species/migrations/0002_trapspecies.py | 29 --- .../migrations/0003_collectionspecies.py | 33 ---- .../0005_DATA_species_collection.py | 41 ----- ccdb/species/migrations/0006_set_labels.py | 34 ---- config/settings/base.py | 8 +- 42 files changed, 588 insertions(+), 1001 deletions(-) rename ccdb/collections_ccdb/migrations/{0005_DATA_initial.py => 0002_DATA_initial.py} (86%) delete mode 100644 ccdb/collections_ccdb/migrations/0002_collection_display_name.py delete mode 100644 ccdb/collections_ccdb/migrations/0003_collections_ordering.py delete mode 100644 ccdb/collections_ccdb/migrations/0004_collections_ordering.py delete mode 100644 ccdb/collections_ccdb/migrations/0006_set_labels.py rename ccdb/experiments/migrations/{0009_DATA_initial.py => 0002_DATA_initial.py} (81%) delete mode 100644 ccdb/experiments/migrations/0002_treatment_type.py delete mode 100644 ccdb/experiments/migrations/0003_treatment.py delete mode 100644 ccdb/experiments/migrations/0004_treatment_replicate.py delete mode 100644 ccdb/experiments/migrations/0005_alivedeadcount.py delete mode 100644 ccdb/experiments/migrations/0006_experiment_collections.py delete mode 100644 ccdb/experiments/migrations/0007_treatment_replicates_display.py delete mode 100644 ccdb/experiments/migrations/0008_treatment_display_name.py delete mode 100644 ccdb/experiments/migrations/0010_DATA_collections_experiments.py delete mode 100644 ccdb/experiments/migrations/0011_set_labels.py rename ccdb/locations/migrations/{0004_DATA_initial.py => 0002_DATA_initial.py} (98%) delete mode 100644 ccdb/locations/migrations/0002_remove_site_fk_dupes.py delete mode 100644 ccdb/locations/migrations/0003_study_location_code_req.py delete mode 100644 ccdb/locations/migrations/0005_set_labels.py delete mode 100644 ccdb/misc/migrations/0003_set_labels.py delete mode 100644 ccdb/processing/migrations/0003_set_labels.py create mode 100644 ccdb/projects/migrations/0001_initial.py delete mode 100644 ccdb/projects/migrations/0001_initial_project.py rename ccdb/projects/migrations/{0005_DATA_initial.py => 0002_DATA_initial.py} (97%) delete mode 100644 ccdb/projects/migrations/0002_initial_grant.py delete mode 100644 ccdb/projects/migrations/0003_grant_projects.py delete mode 100644 ccdb/projects/migrations/0004_initial_grantreport.py delete mode 100644 ccdb/projects/migrations/0006_set_labels.py rename ccdb/species/migrations/{0004_DATA_initial.py => 0002_DATA_initial.py} (93%) delete mode 100644 ccdb/species/migrations/0002_trapspecies.py delete mode 100644 ccdb/species/migrations/0003_collectionspecies.py delete mode 100644 ccdb/species/migrations/0005_DATA_species_collection.py delete mode 100644 ccdb/species/migrations/0006_set_labels.py diff --git a/ccdb/collections_ccdb/migrations/0001_initial.py b/ccdb/collections_ccdb/migrations/0001_initial.py index 402332d..fab79c1 100644 --- a/ccdb/collections_ccdb/migrations/0001_initial.py +++ b/ccdb/collections_ccdb/migrations/0001_initial.py @@ -1,26 +1,22 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ - ('locations', '0002_remove_site_fk_dupes'), - ('projects', '0004_initial_grantreport'), + ('projects', '0002_DATA_initial'), ('processing', '0001_initial'), + ('locations', '0002_DATA_initial'), ] operations = [ migrations.CreateModel( name='ADFGPermit', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), ('name', models.CharField(max_length=200)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ 'ordering': ['sort_order'], @@ -29,25 +25,25 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Collection', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), - ('number_of_traps', models.IntegerField(null=True, blank=True)), - ('collection_start_date', models.DateField(null=True, blank=True)), - ('collection_start_time', models.TimeField(null=True, blank=True)), - ('collection_end_date', models.DateField(null=True, blank=True)), - ('collection_end_time', models.TimeField(null=True, blank=True)), - ('specimen_state', models.CharField(max_length=50, blank=True)), - ('adfg_permit', models.ForeignKey(to='collections_ccdb.ADFGPermit', blank=True, null=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), + ('number_of_traps', models.IntegerField(blank=True, null=True)), + ('collection_start_date', models.DateField(blank=True, null=True)), + ('collection_start_time', models.TimeField(blank=True, null=True)), + ('collection_end_date', models.DateField(blank=True, null=True)), + ('collection_end_time', models.TimeField(blank=True, null=True)), + ('specimen_state', models.CharField(blank=True, max_length=50)), + ('adfg_permit', models.ForeignKey(blank=True, null=True, to='collections_ccdb.ADFGPermit')), ], ), migrations.CreateModel( name='CollectionMethod', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('collection_method_class', models.CharField(max_length=50, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), + ('code', models.CharField(blank=True, max_length=10)), + ('collection_method_class', models.CharField(blank=True, max_length=50)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ 'ordering': ['sort_order'], @@ -56,7 +52,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CollectionTrap', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), ('number_of_traps', models.IntegerField()), ('date_opened', models.DateField()), ('time_opened', models.TimeField()), @@ -68,11 +64,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CollectionType', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), + ('code', models.CharField(blank=True, max_length=10)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ 'ordering': ['sort_order'], @@ -81,19 +77,19 @@ class Migration(migrations.Migration): migrations.CreateModel( name='DatasheetAttachment', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), - ('datasheet', models.FileField(verbose_name='Datasheet', upload_to='collections/datasheets/%Y/%m/%d')), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), + ('datasheet', models.FileField(upload_to='collections/datasheets/%Y/%m/%d', verbose_name='Datasheet')), ('collection', models.ForeignKey(to='collections_ccdb.Collection')), ], ), migrations.CreateModel( name='Flaw', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)), ('name', models.CharField(max_length=200)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ 'ordering': ['sort_order'], @@ -120,12 +116,12 @@ class Migration(migrations.Migration): migrations.AddField( model_name='collection', name='flaw', - field=models.ForeignKey(to='collections_ccdb.Flaw', blank=True, null=True), + field=models.ForeignKey(blank=True, null=True, to='collections_ccdb.Flaw'), ), migrations.AddField( model_name='collection', name='process_type', - field=models.ForeignKey(to='processing.ProcessType', blank=True, null=True), + field=models.ForeignKey(blank=True, null=True, to='processing.ProcessType'), ), migrations.AddField( model_name='collection', @@ -135,12 +131,12 @@ class Migration(migrations.Migration): migrations.AddField( model_name='collection', name='reagent', - field=models.ForeignKey(to='processing.Reagent', blank=True, null=True), + field=models.ForeignKey(blank=True, null=True, to='processing.Reagent'), ), migrations.AddField( model_name='collection', name='storage_location', - field=models.ForeignKey(to='locations.StorageLocation', blank=True, null=True), + field=models.ForeignKey(blank=True, null=True, to='locations.StorageLocation'), ), migrations.AddField( model_name='collection', @@ -155,4 +151,73 @@ class Migration(migrations.Migration): name='collection', unique_together=set([('project', 'study_location', 'collection_type', 'collection_start_date', 'collection_end_date', 'collection_method')]), ), + migrations.AddField( + model_name='collection', + name='display_name', + field=models.CharField(editable=False, default='x', max_length=255), + preserve_default=False, + ), + migrations.AlterModelOptions( + name='collection', + options={'ordering': ['project', 'collection_end_date']}, + ), + migrations.AlterModelOptions( + name='adfgpermit', + options={'ordering': ['sort_order'], 'verbose_name': 'ADFG Permit'}, + ), + migrations.AlterField( + model_name='collection', + name='adfg_permit', + field=models.ForeignKey(related_name='collections', blank=True, null=True, to='collections_ccdb.ADFGPermit'), + ), + migrations.AlterField( + model_name='collection', + name='collection_method', + field=models.ForeignKey(related_name='collections', to='collections_ccdb.CollectionMethod'), + ), + migrations.AlterField( + model_name='collection', + name='collection_type', + field=models.ForeignKey(related_name='collections', to='collections_ccdb.CollectionType'), + ), + migrations.AlterField( + model_name='collection', + name='flaw', + field=models.ForeignKey(related_name='collections', blank=True, null=True, to='collections_ccdb.Flaw'), + ), + migrations.AlterField( + model_name='collection', + name='process_type', + field=models.ForeignKey(related_name='collections', blank=True, null=True, to='processing.ProcessType'), + ), + migrations.AlterField( + model_name='collection', + name='project', + field=models.ForeignKey(related_name='collections', to='projects.Project'), + ), + migrations.AlterField( + model_name='collection', + name='reagent', + field=models.ForeignKey(related_name='collections', blank=True, null=True, to='processing.Reagent'), + ), + migrations.AlterField( + model_name='collection', + name='storage_location', + field=models.ForeignKey(related_name='collections', blank=True, null=True, to='locations.StorageLocation'), + ), + migrations.AlterField( + model_name='collection', + name='study_location', + field=models.ForeignKey(related_name='collections', to='locations.StudyLocation'), + ), + migrations.AlterField( + model_name='collectiontrap', + name='collection', + field=models.ForeignKey(related_name='traps', to='collections_ccdb.Collection'), + ), + migrations.AlterField( + model_name='datasheetattachment', + name='collection', + field=models.ForeignKey(related_name='datasheets', to='collections_ccdb.Collection'), + ), ] diff --git a/ccdb/collections_ccdb/migrations/0005_DATA_initial.py b/ccdb/collections_ccdb/migrations/0002_DATA_initial.py similarity index 86% rename from ccdb/collections_ccdb/migrations/0005_DATA_initial.py rename to ccdb/collections_ccdb/migrations/0002_DATA_initial.py index 417eb0b..b01404d 100644 --- a/ccdb/collections_ccdb/migrations/0005_DATA_initial.py +++ b/ccdb/collections_ccdb/migrations/0002_DATA_initial.py @@ -25,11 +25,15 @@ class Migration(migrations.Migration): model.objects.all().delete() Project = apps.get_model('projects', 'Project') + CollectionSpecies = apps.get_model('species', 'CollectionSpecies') + + CollectionSpecies.objects.all().delete() CollectionTypeForm = modelform_factory(CollectionType, fields='__all__') CollectionMethodForm = modelform_factory(CollectionMethod, fields='__all__') ADFGPermitForm = modelform_factory(ADFGPermit, fields='__all__') CollectionForm = modelform_factory(Collection, fields='__all__') + CollectionSpeciesForm = modelform_factory(CollectionSpecies, fields='__all__') for r in c.execute('SELECT * FROM tbl_lu_collection_types;'): form = CollectionTypeForm(dict(name=r[1], code=r[2], @@ -85,6 +89,15 @@ class Migration(migrations.Migration): else: print('collection', r[0:], form.errors.as_data()) + for r in c.execute('SELECT * FROM tbl_hash_collection_species;'): + form = CollectionSpeciesForm(dict(collection=r[0], species=r[1], sex=r[2], + count=r[3], count_estimated=r[4])) + if form.is_valid(): + # No PK in Andre's file + form.save() + else: + print('collection species', r[0:], form.errors.as_data()) + def rollback(apps, schema_editor): CollectionType = apps.get_model('collections_ccdb', 'CollectionType') CollectionMethod = apps.get_model('collections_ccdb', 'CollectionMethod') @@ -93,13 +106,15 @@ class Migration(migrations.Migration): Collection = apps.get_model('collections_ccdb', 'Collection') DatasheetAttachment = apps.get_model('collections_ccdb', 'DatasheetAttachment') CollectionTrap = apps.get_model('collections_ccdb', 'CollectionTrap') + CollectionSpecies = apps.get_model('species', 'CollectionSpecies') for model in [CollectionTrap, Collection, Flaw, DatasheetAttachment, - CollectionMethod, CollectionType, ADFGPermit]: + CollectionMethod, CollectionType, ADFGPermit, CollectionSpecies]: model.objects.all().delete() dependencies = [ - ('collections_ccdb', '0004_collections_ordering'), + ('collections_ccdb', '0001_initial'), + ('processing', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/collections_ccdb/migrations/0002_collection_display_name.py b/ccdb/collections_ccdb/migrations/0002_collection_display_name.py deleted file mode 100644 index 92a1768..0000000 --- a/ccdb/collections_ccdb/migrations/0002_collection_display_name.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='collection', - name='display_name', - field=models.CharField(max_length=255, editable=False, default='x'), - preserve_default=False, - ), - ] diff --git a/ccdb/collections_ccdb/migrations/0003_collections_ordering.py b/ccdb/collections_ccdb/migrations/0003_collections_ordering.py deleted file mode 100644 index be90402..0000000 --- a/ccdb/collections_ccdb/migrations/0003_collections_ordering.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0002_collection_display_name'), - ] - - operations = [ - migrations.AlterModelOptions( - name='collection', - options={'ordering': ['project', 'collection_end_date']}, - ), - ] diff --git a/ccdb/collections_ccdb/migrations/0004_collections_ordering.py b/ccdb/collections_ccdb/migrations/0004_collections_ordering.py deleted file mode 100644 index cf4f18f..0000000 --- a/ccdb/collections_ccdb/migrations/0004_collections_ordering.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0003_collections_ordering'), - ] - - operations = [ - migrations.AlterModelOptions( - name='adfgpermit', - options={'ordering': ['sort_order'], 'verbose_name': 'ADFG Permit'}, - ), - ] diff --git a/ccdb/collections_ccdb/migrations/0006_set_labels.py b/ccdb/collections_ccdb/migrations/0006_set_labels.py deleted file mode 100644 index a94e081..0000000 --- a/ccdb/collections_ccdb/migrations/0006_set_labels.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0005_DATA_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='collection', - name='adfg_permit', - field=models.ForeignKey(null=True, related_name='collections', to='collections_ccdb.ADFGPermit', blank=True), - ), - migrations.AlterField( - model_name='collection', - name='collection_method', - field=models.ForeignKey(to='collections_ccdb.CollectionMethod', related_name='collections'), - ), - migrations.AlterField( - model_name='collection', - name='collection_type', - field=models.ForeignKey(to='collections_ccdb.CollectionType', related_name='collections'), - ), - migrations.AlterField( - model_name='collection', - name='flaw', - field=models.ForeignKey(null=True, related_name='collections', to='collections_ccdb.Flaw', blank=True), - ), - migrations.AlterField( - model_name='collection', - name='process_type', - field=models.ForeignKey(null=True, related_name='collections', to='processing.ProcessType', blank=True), - ), - migrations.AlterField( - model_name='collection', - name='project', - field=models.ForeignKey(to='projects.Project', related_name='collections'), - ), - migrations.AlterField( - model_name='collection', - name='reagent', - field=models.ForeignKey(null=True, related_name='collections', to='processing.Reagent', blank=True), - ), - migrations.AlterField( - model_name='collection', - name='storage_location', - field=models.ForeignKey(null=True, related_name='collections', to='locations.StorageLocation', blank=True), - ), - migrations.AlterField( - model_name='collection', - name='study_location', - field=models.ForeignKey(to='locations.StudyLocation', related_name='collections'), - ), - migrations.AlterField( - model_name='collectiontrap', - name='collection', - field=models.ForeignKey(to='collections_ccdb.Collection', related_name='traps'), - ), - migrations.AlterField( - model_name='datasheetattachment', - name='collection', - field=models.ForeignKey(to='collections_ccdb.Collection', related_name='datasheets'), - ), - ] diff --git a/ccdb/experiments/migrations/0001_initial.py b/ccdb/experiments/migrations/0001_initial.py index c528c95..a74ddf2 100644 --- a/ccdb/experiments/migrations/0001_initial.py +++ b/ccdb/experiments/migrations/0001_initial.py @@ -1,24 +1,24 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ + ('misc', '0001_initial'), + ('locations', '0001_initial'), + ('collections_ccdb', '0001_initial'), + ('species', '0001_initial'), ] operations = [ migrations.CreateModel( name='Experiment', fields=[ - ('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), ('name', models.CharField(max_length=150)), - ('code', models.CharField(max_length=10, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('code', models.CharField(blank=True, max_length=10)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ @@ -28,10 +28,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Flaw', fields=[ - ('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), ('name', models.CharField(max_length=200)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ @@ -41,7 +41,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='ProtocolAttachment', fields=[ - ('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), ('protocol', models.FileField(upload_to='experiments/protocols/%Y/%m/%d')), ('experiment', models.ForeignKey(to='experiments.Experiment')), ], @@ -55,4 +55,147 @@ class Migration(migrations.Migration): name='experiment', unique_together=set([('name', 'code')]), ), + migrations.CreateModel( + name='TreatmentType', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('code', models.CharField(blank=True, max_length=25)), + ('treatment_type', models.CharField(blank=True, max_length=50)), + ('placement', models.CharField(blank=True, max_length=25)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ('experiment', models.ForeignKey(to='experiments.Experiment', null=True, blank=True)), + ], + options={ + 'ordering': ['sort_order'], + }, + ), + migrations.AlterUniqueTogether( + name='treatmenttype', + unique_together=set([('experiment', 'name')]), + ), + migrations.CreateModel( + name='Treatment', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('sex', models.CharField(max_length=25)), + ('container', models.ForeignKey(to='misc.Container', null=True, blank=True)), + ('flaw', models.ForeignKey(to='experiments.Flaw', null=True, blank=True)), + ('species', models.ForeignKey(to='species.Species')), + ('study_location', models.ForeignKey(to='locations.StudyLocation')), + ('treatment_type', models.ForeignKey(to='experiments.TreatmentType')), + ], + ), + migrations.CreateModel( + name='TreatmentReplicate', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('setup_date', models.DateField(blank=True, null=True)), + ('setup_time', models.TimeField(blank=True, null=True)), + ('setup_sample_size', models.IntegerField(blank=True, null=True)), + ('mass_g', models.FloatField(blank=True, null=True)), + ('flaw', models.ForeignKey(to='experiments.Flaw', null=True, blank=True)), + ('treatment', models.ForeignKey(to='experiments.Treatment')), + ], + ), + migrations.AlterUniqueTogether( + name='treatmentreplicate', + unique_together=set([('treatment', 'name', 'setup_date', 'setup_time')]), + ), + migrations.CreateModel( + name='AliveDeadCount', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('status_date', models.DateField()), + ('status_time', models.TimeField(blank=True, null=True)), + ('count_alive', models.IntegerField(blank=True, null=True)), + ('count_dead', models.IntegerField(blank=True, null=True)), + ('flaw', models.ForeignKey(to='experiments.Flaw', null=True, blank=True)), + ('treatment_replicate', models.ForeignKey(to='experiments.TreatmentReplicate')), + ], + ), + migrations.AddField( + model_name='experiment', + name='collections', + field=models.ManyToManyField(to='collections_ccdb.Collection'), + ), + migrations.AlterModelOptions( + name='alivedeadcount', + options={'verbose_name': 'Alive-dead Count'}, + ), + migrations.AddField( + model_name='treatmentreplicate', + name='display_name', + field=models.CharField(default='x', max_length=255, editable=False), + preserve_default=False, + ), + migrations.AddField( + model_name='treatment', + name='display_name', + field=models.CharField(default='x', max_length=255, editable=False), + preserve_default=False, + ), + migrations.AlterField( + model_name='alivedeadcount', + name='flaw', + field=models.ForeignKey(related_name='alive_dead_counts', to='experiments.Flaw', null=True, blank=True), + ), + migrations.AlterField( + model_name='alivedeadcount', + name='treatment_replicate', + field=models.ForeignKey(related_name='alive_dead_counts', to='experiments.TreatmentReplicate'), + ), + migrations.AlterField( + model_name='experiment', + name='flaw', + field=models.ForeignKey(related_name='experiments', to='experiments.Flaw', null=True, blank=True), + ), + migrations.AlterField( + model_name='protocolattachment', + name='experiment', + field=models.ForeignKey(related_name='protocols', to='experiments.Experiment'), + ), + migrations.AlterField( + model_name='treatment', + name='container', + field=models.ForeignKey(related_name='treatments', to='misc.Container', null=True, blank=True), + ), + migrations.AlterField( + model_name='treatment', + name='flaw', + field=models.ForeignKey(related_name='treatments', to='experiments.Flaw', null=True, blank=True), + ), + migrations.AlterField( + model_name='treatment', + name='species', + field=models.ForeignKey(related_name='treatments', to='species.Species'), + ), + migrations.AlterField( + model_name='treatment', + name='study_location', + field=models.ForeignKey(related_name='treatments', to='locations.StudyLocation'), + ), + migrations.AlterField( + model_name='treatment', + name='treatment_type', + field=models.ForeignKey(related_name='treatments', to='experiments.TreatmentType'), + ), + migrations.AlterField( + model_name='treatmentreplicate', + name='flaw', + field=models.ForeignKey(related_name='treatment_replicates', to='experiments.Flaw', null=True, blank=True), + ), + migrations.AlterField( + model_name='treatmentreplicate', + name='treatment', + field=models.ForeignKey(related_name='treatment_replicates', to='experiments.Treatment'), + ), + migrations.AlterField( + model_name='treatmenttype', + name='experiment', + field=models.ForeignKey(related_name='treatment_types', to='experiments.Experiment', null=True, blank=True), + ), ] diff --git a/ccdb/experiments/migrations/0009_DATA_initial.py b/ccdb/experiments/migrations/0002_DATA_initial.py similarity index 81% rename from ccdb/experiments/migrations/0009_DATA_initial.py rename to ccdb/experiments/migrations/0002_DATA_initial.py index 8fc3ff8..a62e7c2 100644 --- a/ccdb/experiments/migrations/0009_DATA_initial.py +++ b/ccdb/experiments/migrations/0002_DATA_initial.py @@ -23,6 +23,10 @@ class Migration(migrations.Migration): Experiment, Flaw]: model.objects.all().delete() + Collection = apps.get_model('collections_ccdb', 'Collection') + StudyLocation = apps.get_model('locations', 'StudyLocation') + Species = apps.get_model('species', 'Species') + ExperimentForm = modelform_factory(Experiment, exclude=('collections',)) TreatmentTypeForm = modelform_factory(TreatmentType, fields='__all__') TreatmentForm = modelform_factory(Treatment, fields='__all__') @@ -50,7 +54,12 @@ class Migration(migrations.Migration): form = TreatmentForm(dict(treatment_type=r[1], container=r[2], study_location=r[3], species=r[4], sex=r[5])) if form.is_valid(): - Treatment.objects.create(id=r[0], **form.cleaned_data) + treatment_type = TreatmentType.objects.get(id=r[1]) + study_location = StudyLocation.objects.get(id=r[3]) + species = Species.objects.get(id=r[4]) + d = "{}_{}_{}_{}".format(treatment_type, study_location, + species, form.cleaned_data['sex']) + Treatment.objects.create(id=r[0], display_name=d, **form.cleaned_data) else: print('treatment', r[0:], form.errors.as_data()) @@ -91,6 +100,17 @@ class Migration(migrations.Migration): else: print('alive-dead count', r[0:], form.errors.as_data()) + + + for experiment in Experiment.objects.all(): + experiment.collections.all().delete() + + for r in c.execute('SELECT * FROM tbl_hash_collection_experiments;'): + c = Collection.objects.get(id=r[0]) + e = Experiment.objects.get(id=r[1]) + e.collections.add(c) + e.save() + def rollback(apps, schema_editor): Flaw = apps.get_model('experiments', 'Flaw') Experiment = apps.get_model('experiments', 'Experiment') @@ -103,9 +123,13 @@ class Migration(migrations.Migration): Experiment, Flaw]: model.objects.all().delete() + for experiment in Experiment.objects.all(): + experiment.collections.all().delete() + + dependencies = [ - ('experiments', '0008_treatment_display_name'), - ('collections_ccdb', '0005_DATA_initial'), + ('experiments', '0001_initial'), + ('collections_ccdb', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/experiments/migrations/0002_treatment_type.py b/ccdb/experiments/migrations/0002_treatment_type.py deleted file mode 100644 index f1d050a..0000000 --- a/ccdb/experiments/migrations/0002_treatment_type.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models -import autoslug.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='TreatmentType', - fields=[ - ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), - ('name', models.CharField(max_length=200)), - ('code', models.CharField(max_length=25, blank=True)), - ('treatment_type', models.CharField(max_length=50, blank=True)), - ('placement', models.CharField(max_length=25, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), - ('experiment', models.ForeignKey(null=True, blank=True, to='experiments.Experiment')), - ], - options={ - 'ordering': ['sort_order'], - }, - ), - migrations.AlterUniqueTogether( - name='treatmenttype', - unique_together=set([('experiment', 'name')]), - ), - ] diff --git a/ccdb/experiments/migrations/0003_treatment.py b/ccdb/experiments/migrations/0003_treatment.py deleted file mode 100644 index 27c9d50..0000000 --- a/ccdb/experiments/migrations/0003_treatment.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('misc', '0001_initial'), - ('species', '0003_collectionspecies'), - ('locations', '0002_remove_site_fk_dupes'), - ('experiments', '0002_treatment_type'), - ] - - operations = [ - migrations.CreateModel( - name='Treatment', - fields=[ - ('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)), - ('sex', models.CharField(max_length=25)), - ('container', models.ForeignKey(blank=True, null=True, to='misc.Container')), - ('flaw', models.ForeignKey(blank=True, null=True, to='experiments.Flaw')), - ('species', models.ForeignKey(to='species.Species')), - ('study_location', models.ForeignKey(to='locations.StudyLocation')), - ('treatment_type', models.ForeignKey(to='experiments.TreatmentType')), - ], - ), - ] diff --git a/ccdb/experiments/migrations/0004_treatment_replicate.py b/ccdb/experiments/migrations/0004_treatment_replicate.py deleted file mode 100644 index 40fe20e..0000000 --- a/ccdb/experiments/migrations/0004_treatment_replicate.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0003_treatment'), - ] - - operations = [ - migrations.CreateModel( - name='TreatmentReplicate', - fields=[ - ('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=50)), - ('setup_date', models.DateField(null=True, blank=True)), - ('setup_time', models.TimeField(null=True, blank=True)), - ('setup_sample_size', models.IntegerField(null=True, blank=True)), - ('mass_g', models.FloatField(null=True, blank=True)), - ('flaw', models.ForeignKey(null=True, to='experiments.Flaw', blank=True)), - ('treatment', models.ForeignKey(to='experiments.Treatment')), - ], - ), - migrations.AlterUniqueTogether( - name='treatmentreplicate', - unique_together=set([('treatment', 'name', 'setup_date', 'setup_time')]), - ), - ] diff --git a/ccdb/experiments/migrations/0005_alivedeadcount.py b/ccdb/experiments/migrations/0005_alivedeadcount.py deleted file mode 100644 index 94815a1..0000000 --- a/ccdb/experiments/migrations/0005_alivedeadcount.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0004_treatment_replicate'), - ] - - operations = [ - migrations.CreateModel( - name='AliveDeadCount', - fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), - ('status_date', models.DateField()), - ('status_time', models.TimeField(blank=True, null=True)), - ('count_alive', models.IntegerField(blank=True, null=True)), - ('count_dead', models.IntegerField(blank=True, null=True)), - ('flaw', models.ForeignKey(to='experiments.Flaw', blank=True, null=True)), - ('treatment_replicate', models.ForeignKey(to='experiments.TreatmentReplicate')), - ], - ), - ] diff --git a/ccdb/experiments/migrations/0006_experiment_collections.py b/ccdb/experiments/migrations/0006_experiment_collections.py deleted file mode 100644 index 5bf2293..0000000 --- a/ccdb/experiments/migrations/0006_experiment_collections.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0001_initial'), - ('experiments', '0005_alivedeadcount'), - ] - - operations = [ - migrations.AddField( - model_name='experiment', - name='collections', - field=models.ManyToManyField(to='collections_ccdb.Collection'), - ), - ] diff --git a/ccdb/experiments/migrations/0007_treatment_replicates_display.py b/ccdb/experiments/migrations/0007_treatment_replicates_display.py deleted file mode 100644 index cc8581f..0000000 --- a/ccdb/experiments/migrations/0007_treatment_replicates_display.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0006_experiment_collections'), - ] - - operations = [ - migrations.AlterModelOptions( - name='alivedeadcount', - options={'verbose_name': 'Alive-dead Count'}, - ), - migrations.AddField( - model_name='treatmentreplicate', - name='display_name', - field=models.CharField(editable=False, max_length=255, default='x'), - preserve_default=False, - ), - ] diff --git a/ccdb/experiments/migrations/0008_treatment_display_name.py b/ccdb/experiments/migrations/0008_treatment_display_name.py deleted file mode 100644 index 7323a87..0000000 --- a/ccdb/experiments/migrations/0008_treatment_display_name.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0007_treatment_replicates_display'), - ] - - operations = [ - migrations.AddField( - model_name='treatment', - name='display_name', - field=models.CharField(editable=False, default='x', max_length=255), - preserve_default=False, - ), - ] diff --git a/ccdb/experiments/migrations/0010_DATA_collections_experiments.py b/ccdb/experiments/migrations/0010_DATA_collections_experiments.py deleted file mode 100644 index 4118eb5..0000000 --- a/ccdb/experiments/migrations/0010_DATA_collections_experiments.py +++ /dev/null @@ -1,38 +0,0 @@ -from django.db import migrations - -from ccdb.utils.data import get_data_sources - - -class Migration(migrations.Migration): - def migrate(apps, schema_editor): - sources = get_data_sources() - if not sources: - return - - c = sources['db0'] - - Collection = apps.get_model('collections_ccdb', 'Collection') - Experiment = apps.get_model('experiments', 'Experiment') - - for experiment in Experiment.objects.all(): - experiment.collections.all().delete() - - for r in c.execute('SELECT * FROM tbl_hash_collection_experiments;'): - c = Collection.objects.get(id=r[0]) - e = Experiment.objects.get(id=r[1]) - e.collections.add(c) - e.save() - - def rollback(apps, schema_editor): - Experiment = apps.get_model('experiments', 'Experiment') - - for experiment in Experiment.objects.all(): - experiment.collections.all().delete() - - dependencies = [ - ('experiments', '0009_DATA_initial'), - ] - - operations = [ - migrations.RunPython(migrate, rollback), - ] diff --git a/ccdb/experiments/migrations/0011_set_labels.py b/ccdb/experiments/migrations/0011_set_labels.py deleted file mode 100644 index 9705a6f..0000000 --- a/ccdb/experiments/migrations/0011_set_labels.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0010_DATA_collections_experiments'), - ] - - operations = [ - migrations.AlterField( - model_name='alivedeadcount', - name='flaw', - field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='alive_dead_counts', blank=True), - ), - migrations.AlterField( - model_name='alivedeadcount', - name='treatment_replicate', - field=models.ForeignKey(to='experiments.TreatmentReplicate', related_name='alive_dead_counts'), - ), - migrations.AlterField( - model_name='experiment', - name='flaw', - field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='experiments', blank=True), - ), - migrations.AlterField( - model_name='protocolattachment', - name='experiment', - field=models.ForeignKey(to='experiments.Experiment', related_name='protocols'), - ), - migrations.AlterField( - model_name='treatment', - name='container', - field=models.ForeignKey(null=True, to='misc.Container', related_name='treatments', blank=True), - ), - migrations.AlterField( - model_name='treatment', - name='flaw', - field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='treatments', blank=True), - ), - migrations.AlterField( - model_name='treatment', - name='species', - field=models.ForeignKey(to='species.Species', related_name='treatments'), - ), - migrations.AlterField( - model_name='treatment', - name='study_location', - field=models.ForeignKey(to='locations.StudyLocation', related_name='treatments'), - ), - migrations.AlterField( - model_name='treatment', - name='treatment_type', - field=models.ForeignKey(to='experiments.TreatmentType', related_name='treatments'), - ), - migrations.AlterField( - model_name='treatmentreplicate', - name='flaw', - field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='treatment_replicates', blank=True), - ), - migrations.AlterField( - model_name='treatmentreplicate', - name='treatment', - field=models.ForeignKey(to='experiments.Treatment', related_name='treatment_replicates'), - ), - migrations.AlterField( - model_name='treatmenttype', - name='experiment', - field=models.ForeignKey(null=True, to='experiments.Experiment', related_name='treatment_types', blank=True), - ), - ] diff --git a/ccdb/locations/migrations/0001_initial.py b/ccdb/locations/migrations/0001_initial.py index f75adf8..e77cdf9 100644 --- a/ccdb/locations/migrations/0001_initial.py +++ b/ccdb/locations/migrations/0001_initial.py @@ -1,12 +1,8 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ ] @@ -14,13 +10,13 @@ class Migration(migrations.Migration): migrations.CreateModel( name='MunicipalLocation', fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('municipal_location_type', models.CharField(max_length=50, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ('code', models.CharField(blank=True, max_length=10)), + ('municipal_location_type', models.CharField(blank=True, max_length=50)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ 'ordering': ['sort_order'], @@ -29,11 +25,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Region', fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ('code', models.CharField(blank=True, max_length=10)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ 'ordering': ['sort_order'], @@ -42,12 +38,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Site', fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ('code', models.CharField(blank=True, max_length=10)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ('region', models.ForeignKey(to='locations.Region', null=True, blank=True)), ], options={ @@ -57,15 +53,15 @@ class Migration(migrations.Migration): migrations.CreateModel( name='StorageLocation', fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('facility', models.CharField(max_length=100)), ('building', models.CharField(max_length=100)), ('code', models.CharField(max_length=100)), - ('room', models.CharField(max_length=50, blank=True)), - ('freezer', models.CharField(max_length=50, blank=True)), - ('temp_c', models.IntegerField(null=True, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('room', models.CharField(blank=True, max_length=50)), + ('freezer', models.CharField(blank=True, max_length=50)), + ('temp_c', models.IntegerField(blank=True, null=True)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), ], options={ 'ordering': ['sort_order'], @@ -74,15 +70,15 @@ class Migration(migrations.Migration): migrations.CreateModel( name='StudyLocation', fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('study_location_type', models.CharField(max_length=50, blank=True)), - ('treatment_type', models.CharField(max_length=100, blank=True)), + ('code', models.CharField(blank=True, max_length=10)), + ('study_location_type', models.CharField(blank=True, max_length=50)), + ('treatment_type', models.CharField(blank=True, max_length=100)), ('collecting_location', models.BooleanField(default=False)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ('municipal_location', models.ForeignKey(to='locations.MunicipalLocation', null=True, blank=True)), ('site', models.ForeignKey(to='locations.Site', null=True, blank=True)), ], @@ -94,13 +90,33 @@ class Migration(migrations.Migration): name='region', unique_together=set([('name', 'code')]), ), - migrations.AddField( - model_name='municipallocation', - name='site', - field=models.ForeignKey(to='locations.Site'), - ), migrations.AlterUniqueTogether( name='studylocation', unique_together=set([('site', 'name')]), ), + migrations.AlterField( + model_name='studylocation', + name='site', + field=models.ForeignKey(to='locations.Site'), + ), + migrations.AlterField( + model_name='studylocation', + name='code', + field=models.CharField(max_length=10), + ), + migrations.AlterField( + model_name='site', + name='region', + field=models.ForeignKey(to='locations.Region', null=True, blank=True, related_name='sites'), + ), + migrations.AlterField( + model_name='studylocation', + name='municipal_location', + field=models.ForeignKey(to='locations.MunicipalLocation', null=True, blank=True, related_name='study_locations'), + ), + migrations.AlterField( + model_name='studylocation', + name='site', + field=models.ForeignKey(to='locations.Site', related_name='study_locations'), + ), ] diff --git a/ccdb/locations/migrations/0004_DATA_initial.py b/ccdb/locations/migrations/0002_DATA_initial.py similarity index 98% rename from ccdb/locations/migrations/0004_DATA_initial.py rename to ccdb/locations/migrations/0002_DATA_initial.py index f586a15..148162b 100644 --- a/ccdb/locations/migrations/0004_DATA_initial.py +++ b/ccdb/locations/migrations/0002_DATA_initial.py @@ -94,7 +94,8 @@ class Migration(migrations.Migration): model.objects.all().delete() dependencies = [ - ('locations', '0003_study_location_code_req'), + ('locations', '0001_initial'), + ('misc', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/locations/migrations/0002_remove_site_fk_dupes.py b/ccdb/locations/migrations/0002_remove_site_fk_dupes.py deleted file mode 100644 index cb6dcb7..0000000 --- a/ccdb/locations/migrations/0002_remove_site_fk_dupes.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('locations', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='municipallocation', - name='site', - ), - migrations.AlterField( - model_name='studylocation', - name='site', - field=models.ForeignKey(to='locations.Site'), - ), - ] diff --git a/ccdb/locations/migrations/0003_study_location_code_req.py b/ccdb/locations/migrations/0003_study_location_code_req.py deleted file mode 100644 index 644f905..0000000 --- a/ccdb/locations/migrations/0003_study_location_code_req.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('locations', '0002_remove_site_fk_dupes'), - ] - - operations = [ - migrations.AlterField( - model_name='studylocation', - name='code', - field=models.CharField(max_length=10), - ), - ] diff --git a/ccdb/locations/migrations/0005_set_labels.py b/ccdb/locations/migrations/0005_set_labels.py deleted file mode 100644 index 8e1ee1b..0000000 --- a/ccdb/locations/migrations/0005_set_labels.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('locations', '0004_DATA_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='site', - name='region', - field=models.ForeignKey(blank=True, related_name='sites', null=True, to='locations.Region'), - ), - migrations.AlterField( - model_name='studylocation', - name='municipal_location', - field=models.ForeignKey(blank=True, related_name='study_locations', null=True, to='locations.MunicipalLocation'), - ), - migrations.AlterField( - model_name='studylocation', - name='site', - field=models.ForeignKey(related_name='study_locations', to='locations.Site'), - ), - ] diff --git a/ccdb/misc/migrations/0001_initial.py b/ccdb/misc/migrations/0001_initial.py index 0c78d8d..760ddc3 100644 --- a/ccdb/misc/migrations/0001_initial.py +++ b/ccdb/misc/migrations/0001_initial.py @@ -1,12 +1,8 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ ] @@ -14,11 +10,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Color', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=50)), - ('code', models.CharField(blank=True, max_length=10)), - ('color_number', models.FloatField(null=True, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('color_number', models.FloatField(blank=True, null=True)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ @@ -28,14 +24,14 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Container', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(blank=True, max_length=10)), - ('application', models.CharField(blank=True, max_length=50)), - ('volume', models.FloatField(null=True, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('application', models.CharField(max_length=50, blank=True)), + ('volume', models.FloatField(blank=True, null=True)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), - ('color', models.ForeignKey(null=True, to='misc.Color', blank=True)), + ('color', models.ForeignKey(blank=True, to='misc.Color', null=True)), ], options={ 'ordering': ['sort_order'], @@ -44,12 +40,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Material', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(blank=True, max_length=10)), - ('material_class', models.CharField(blank=True, max_length=50)), - ('description', models.CharField(blank=True, max_length=255)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('material_class', models.CharField(max_length=50, blank=True)), + ('description', models.CharField(max_length=255, blank=True)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ @@ -59,12 +55,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='MeasurementType', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(blank=True, max_length=10)), - ('measurement_type_class', models.CharField(blank=True, max_length=50)), - ('description', models.CharField(blank=True, max_length=255)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('measurement_type_class', models.CharField(max_length=50, blank=True)), + ('description', models.CharField(max_length=255, blank=True)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ @@ -74,12 +70,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='MeasurementUnit', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')), + ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)), ('name', models.CharField(max_length=100)), ('code', models.CharField(max_length=25)), - ('unit_class', models.CharField(blank=True, max_length=50)), - ('description', models.CharField(blank=True, max_length=255)), - ('sort_order', models.IntegerField(null=True, blank=True)), + ('unit_class', models.CharField(max_length=50, blank=True)), + ('description', models.CharField(max_length=255, blank=True)), + ('sort_order', models.IntegerField(blank=True, null=True)), ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name')), ], options={ @@ -93,7 +89,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='measurementtype', name='default_measurement_unit', - field=models.ForeignKey(null=True, to='misc.MeasurementUnit', blank=True), + field=models.ForeignKey(blank=True, to='misc.MeasurementUnit', null=True), ), migrations.AlterUniqueTogether( name='material', @@ -102,15 +98,35 @@ class Migration(migrations.Migration): migrations.AddField( model_name='container', name='material', - field=models.ForeignKey(null=True, to='misc.Material', blank=True), + field=models.ForeignKey(blank=True, to='misc.Material', null=True), ), migrations.AddField( model_name='container', name='measurement_unit', - field=models.ForeignKey(null=True, to='misc.MeasurementUnit', blank=True), + field=models.ForeignKey(blank=True, to='misc.MeasurementUnit', null=True), ), migrations.AlterUniqueTogether( name='color', unique_together=set([('name', 'code', 'color_number')]), ), + migrations.AlterField( + model_name='container', + name='color', + field=models.ForeignKey(blank=True, to='misc.Color', related_name='containers', null=True), + ), + migrations.AlterField( + model_name='container', + name='material', + field=models.ForeignKey(blank=True, to='misc.Material', related_name='containers', null=True), + ), + migrations.AlterField( + model_name='container', + name='measurement_unit', + field=models.ForeignKey(blank=True, to='misc.MeasurementUnit', related_name='containers', null=True), + ), + migrations.AlterField( + model_name='measurementtype', + name='default_measurement_unit', + field=models.ForeignKey(blank=True, to='misc.MeasurementUnit', related_name='measurement_types', null=True), + ), ] diff --git a/ccdb/misc/migrations/0002_DATA_initial.py b/ccdb/misc/migrations/0002_DATA_initial.py index 30d639c..9d7f51a 100644 --- a/ccdb/misc/migrations/0002_DATA_initial.py +++ b/ccdb/misc/migrations/0002_DATA_initial.py @@ -104,6 +104,7 @@ class Migration(migrations.Migration): dependencies = [ ('misc', '0001_initial'), + ('projects', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/misc/migrations/0003_set_labels.py b/ccdb/misc/migrations/0003_set_labels.py deleted file mode 100644 index 98ba21a..0000000 --- a/ccdb/misc/migrations/0003_set_labels.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('misc', '0002_DATA_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='container', - name='color', - field=models.ForeignKey(related_name='containers', blank=True, to='misc.Color', null=True), - ), - migrations.AlterField( - model_name='container', - name='material', - field=models.ForeignKey(related_name='containers', blank=True, to='misc.Material', null=True), - ), - migrations.AlterField( - model_name='container', - name='measurement_unit', - field=models.ForeignKey(related_name='containers', blank=True, to='misc.MeasurementUnit', null=True), - ), - migrations.AlterField( - model_name='measurementtype', - name='default_measurement_unit', - field=models.ForeignKey(related_name='measurement_types', blank=True, to='misc.MeasurementUnit', null=True), - ), - ] diff --git a/ccdb/processing/migrations/0001_initial.py b/ccdb/processing/migrations/0001_initial.py index d471501..9c1c53c 100644 --- a/ccdb/processing/migrations/0001_initial.py +++ b/ccdb/processing/migrations/0001_initial.py @@ -1,12 +1,8 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ ('misc', '0001_initial'), ] @@ -15,10 +11,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Flaw', fields=[ - ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), + ('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)), ('name', models.CharField(max_length=200)), - ('description', models.CharField(blank=True, max_length=255)), - ('sort_order', models.IntegerField(blank=True, null=True)), + ('description', models.CharField(max_length=255, blank=True)), + ('sort_order', models.IntegerField(null=True, blank=True)), ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ @@ -28,25 +24,25 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Processing', fields=[ - ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), + ('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)), ('container_label', models.CharField(max_length=50)), - ('process_date', models.DateField(blank=True, null=True)), - ('process_time', models.TimeField(blank=True, null=True)), - ('reagent_volume', models.FloatField(blank=True, null=True)), - ('minutes_in_reagent', models.IntegerField(blank=True, null=True)), + ('process_date', models.DateField(null=True, blank=True)), + ('process_time', models.TimeField(null=True, blank=True)), + ('reagent_volume', models.FloatField(null=True, blank=True)), + ('minutes_in_reagent', models.IntegerField(null=True, blank=True)), ('container', models.ForeignKey(to='misc.Container')), - ('flaw', models.ForeignKey(to='processing.Flaw', blank=True, null=True)), - ('measurement_unit', models.ForeignKey(to='misc.MeasurementUnit', blank=True, null=True)), + ('flaw', models.ForeignKey(to='processing.Flaw', null=True, blank=True)), + ('measurement_unit', models.ForeignKey(to='misc.MeasurementUnit', null=True, blank=True)), ], ), migrations.CreateModel( name='ProcessType', fields=[ - ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), + ('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(blank=True, max_length=10)), - ('description', models.CharField(blank=True, max_length=255)), - ('sort_order', models.IntegerField(blank=True, null=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('description', models.CharField(max_length=255, blank=True)), + ('sort_order', models.IntegerField(null=True, blank=True)), ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ @@ -56,11 +52,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Reagent', fields=[ - ('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)), + ('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)), ('name', models.CharField(max_length=100)), - ('code', models.CharField(blank=True, max_length=10)), - ('reagent_class', models.CharField(blank=True, max_length=50)), - ('sort_order', models.IntegerField(blank=True, null=True)), + ('code', models.CharField(max_length=10, blank=True)), + ('reagent_class', models.CharField(max_length=50, blank=True)), + ('sort_order', models.IntegerField(null=True, blank=True)), ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), ], options={ @@ -83,10 +79,35 @@ class Migration(migrations.Migration): migrations.AddField( model_name='processing', name='reagent', - field=models.ForeignKey(to='processing.Reagent', blank=True, null=True), + field=models.ForeignKey(to='processing.Reagent', null=True, blank=True), ), migrations.AlterUniqueTogether( name='processing', unique_together=set([('process_type', 'container', 'container_label', 'process_date', 'process_time', 'reagent')]), ), + migrations.AlterField( + model_name='processing', + name='container', + field=models.ForeignKey(related_name='processings', to='misc.Container'), + ), + migrations.AlterField( + model_name='processing', + name='flaw', + field=models.ForeignKey(to='processing.Flaw', null=True, related_name='processings', blank=True), + ), + migrations.AlterField( + model_name='processing', + name='measurement_unit', + field=models.ForeignKey(to='misc.MeasurementUnit', null=True, related_name='processings', blank=True), + ), + migrations.AlterField( + model_name='processing', + name='process_type', + field=models.ForeignKey(related_name='processings', to='processing.ProcessType'), + ), + migrations.AlterField( + model_name='processing', + name='reagent', + field=models.ForeignKey(to='processing.Reagent', null=True, related_name='processings', blank=True), + ), ] diff --git a/ccdb/processing/migrations/0002_DATA_initial.py b/ccdb/processing/migrations/0002_DATA_initial.py index 2934a22..212a450 100644 --- a/ccdb/processing/migrations/0002_DATA_initial.py +++ b/ccdb/processing/migrations/0002_DATA_initial.py @@ -50,6 +50,7 @@ class Migration(migrations.Migration): dependencies = [ ('processing', '0001_initial'), + ('species', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/processing/migrations/0003_set_labels.py b/ccdb/processing/migrations/0003_set_labels.py deleted file mode 100644 index fe58c6e..0000000 --- a/ccdb/processing/migrations/0003_set_labels.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('processing', '0002_DATA_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='processing', - name='container', - field=models.ForeignKey(related_name='processings', to='misc.Container'), - ), - migrations.AlterField( - model_name='processing', - name='flaw', - field=models.ForeignKey(to='processing.Flaw', blank=True, related_name='processings', null=True), - ), - migrations.AlterField( - model_name='processing', - name='measurement_unit', - field=models.ForeignKey(to='misc.MeasurementUnit', blank=True, related_name='processings', null=True), - ), - migrations.AlterField( - model_name='processing', - name='process_type', - field=models.ForeignKey(related_name='processings', to='processing.ProcessType'), - ), - migrations.AlterField( - model_name='processing', - name='reagent', - field=models.ForeignKey(to='processing.Reagent', blank=True, related_name='processings', null=True), - ), - ] diff --git a/ccdb/projects/migrations/0001_initial.py b/ccdb/projects/migrations/0001_initial.py new file mode 100644 index 0000000..9d01e59 --- /dev/null +++ b/ccdb/projects/migrations/0001_initial.py @@ -0,0 +1,77 @@ +from django.db import migrations, models +import autoslug.fields + + +class Migration(migrations.Migration): + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Project', + fields=[ + ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), + ('name', models.CharField(max_length=100)), + ('code', models.CharField(blank=True, max_length=10)), + ('iacuc_number', models.CharField(blank=True, max_length=25)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), + ], + options={ + 'ordering': ['sort_order'], + }, + ), + migrations.AlterUniqueTogether( + name='project', + unique_together=set([('name', 'code')]), + ), + migrations.CreateModel( + name='Grant', + fields=[ + ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), + ('title', models.CharField(max_length=200)), + ('code', models.CharField(blank=True, max_length=10)), + ('description', models.CharField(blank=True, max_length=255)), + ('sort_order', models.IntegerField(blank=True, null=True)), + ], + options={ + 'ordering': ['sort_order'], + }, + ), + migrations.AlterUniqueTogether( + name='grant', + unique_together=set([('title', 'code')]), + ), + migrations.AddField( + model_name='grant', + name='projects', + field=models.ManyToManyField(related_name='grants', to='projects.Project'), + ), + migrations.CreateModel( + name='GrantReport', + fields=[ + ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), + ('title', models.CharField(max_length=200)), + ('report_type', models.CharField(blank=True, max_length=50)), + ('description', models.CharField(blank=True, max_length=255)), + ('due_date', models.DateField(blank=True, null=True)), + ('submitted_date', models.DateField(blank=True, null=True)), + ('attachment', models.FileField(blank=True, null=True, upload_to='projects/grants/grant_report_attachments/%Y/%m/%d')), + ('sort_order', models.IntegerField(blank=True, null=True)), + ('grant', models.ForeignKey(to='projects.Grant')), + ], + options={ + 'ordering': ['sort_order'], + }, + ), + migrations.AlterUniqueTogether( + name='grantreport', + unique_together=set([('grant', 'title', 'due_date')]), + ), + migrations.AlterField( + model_name='grantreport', + name='grant', + field=models.ForeignKey(related_name='reports', to='projects.Grant'), + ), + ] diff --git a/ccdb/projects/migrations/0001_initial_project.py b/ccdb/projects/migrations/0001_initial_project.py deleted file mode 100644 index d2d460f..0000000 --- a/ccdb/projects/migrations/0001_initial_project.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models -import autoslug.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Project', - fields=[ - ('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('code', models.CharField(max_length=10, blank=True)), - ('iacuc_number', models.CharField(max_length=25, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)), - ], - options={ - 'ordering': ['sort_order'], - }, - ), - migrations.AlterUniqueTogether( - name='project', - unique_together=set([('name', 'code')]), - ), - ] diff --git a/ccdb/projects/migrations/0005_DATA_initial.py b/ccdb/projects/migrations/0002_DATA_initial.py similarity index 97% rename from ccdb/projects/migrations/0005_DATA_initial.py rename to ccdb/projects/migrations/0002_DATA_initial.py index d2b48c6..5e8e418 100644 --- a/ccdb/projects/migrations/0005_DATA_initial.py +++ b/ccdb/projects/migrations/0002_DATA_initial.py @@ -8,7 +8,6 @@ class Migration(migrations.Migration): def migrate(apps, schema_editor): sources = get_data_sources() if not sources: - print('no sources') return c = sources['db0'] @@ -75,7 +74,7 @@ class Migration(migrations.Migration): model.objects.all().delete() dependencies = [ - ('projects', '0004_initial_grantreport'), + ('projects', '0001_initial'), ] operations = [ diff --git a/ccdb/projects/migrations/0002_initial_grant.py b/ccdb/projects/migrations/0002_initial_grant.py deleted file mode 100644 index e2fd99e..0000000 --- a/ccdb/projects/migrations/0002_initial_grant.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0001_initial_project'), - ] - - operations = [ - migrations.CreateModel( - name='Grant', - fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), - ('title', models.CharField(max_length=200)), - ('code', models.CharField(max_length=10, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('sort_order', models.IntegerField(null=True, blank=True)), - ], - options={ - 'ordering': ['sort_order'], - }, - ), - migrations.AlterUniqueTogether( - name='grant', - unique_together=set([('title', 'code')]), - ), - ] diff --git a/ccdb/projects/migrations/0003_grant_projects.py b/ccdb/projects/migrations/0003_grant_projects.py deleted file mode 100644 index f226025..0000000 --- a/ccdb/projects/migrations/0003_grant_projects.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0002_initial_grant'), - ] - - operations = [ - migrations.AddField( - model_name='grant', - name='projects', - field=models.ManyToManyField(to='projects.Project', related_name='grants'), - ), - ] diff --git a/ccdb/projects/migrations/0004_initial_grantreport.py b/ccdb/projects/migrations/0004_initial_grantreport.py deleted file mode 100644 index 3d81a33..0000000 --- a/ccdb/projects/migrations/0004_initial_grantreport.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0003_grant_projects'), - ] - - operations = [ - migrations.CreateModel( - name='GrantReport', - fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), - ('title', models.CharField(max_length=200)), - ('report_type', models.CharField(max_length=50, blank=True)), - ('description', models.CharField(max_length=255, blank=True)), - ('due_date', models.DateField(blank=True, null=True)), - ('submitted_date', models.DateField(blank=True, null=True)), - ('attachment', models.FileField(upload_to='projects/grants/grant_report_attachments/%Y/%m/%d', blank=True, null=True)), - ('sort_order', models.IntegerField(blank=True, null=True)), - ('grant', models.ForeignKey(to='projects.Grant')), - ], - options={ - 'ordering': ['sort_order'], - }, - ), - migrations.AlterUniqueTogether( - name='grantreport', - unique_together=set([('grant', 'title', 'due_date')]), - ), - ] diff --git a/ccdb/projects/migrations/0006_set_labels.py b/ccdb/projects/migrations/0006_set_labels.py deleted file mode 100644 index de82417..0000000 --- a/ccdb/projects/migrations/0006_set_labels.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0005_DATA_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='grantreport', - name='grant', - field=models.ForeignKey(to='projects.Grant', related_name='reports'), - ), - ] diff --git a/ccdb/species/migrations/0001_initial.py b/ccdb/species/migrations/0001_initial.py index cc2dcf5..14104b4 100644 --- a/ccdb/species/migrations/0001_initial.py +++ b/ccdb/species/migrations/0001_initial.py @@ -1,26 +1,23 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import autoslug.fields class Migration(migrations.Migration): - dependencies = [ + ('collections_ccdb', '0001_initial'), ] operations = [ migrations.CreateModel( name='Species', fields=[ - ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), + ('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)), ('common_name', models.CharField(max_length=100)), ('genus', models.CharField(max_length=50, blank=True)), ('species', models.CharField(max_length=50, blank=True)), ('parasite', models.BooleanField(default=False)), ('sort_order', models.IntegerField(blank=True, null=True)), - ('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='common_name')), + ('slug', autoslug.fields.AutoSlugField(populate_from='common_name', editable=False)), ], options={ 'ordering': ['sort_order'], @@ -31,4 +28,56 @@ class Migration(migrations.Migration): name='species', unique_together=set([('common_name', 'species')]), ), + migrations.CreateModel( + name='TrapSpecies', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)), + ('sex', models.CharField(max_length=25, blank=True)), + ('count', models.IntegerField(blank=True, null=True)), + ('count_estimated', models.BooleanField(default=False)), + ('collection_trap', models.ForeignKey(to='collections_ccdb.CollectionTrap')), + ('species', models.ForeignKey(to='species.Species')), + ], + options={ + 'verbose_name_plural': 'trap-species', + }, + ), + migrations.CreateModel( + name='CollectionSpecies', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)), + ('sex', models.CharField(max_length=25, blank=True)), + ('count', models.IntegerField(blank=True, null=True)), + ('count_estimated', models.BooleanField(default=False)), + ('collection', models.ForeignKey(to='collections_ccdb.Collection')), + ('species', models.ForeignKey(to='species.Species')), + ], + options={ + 'verbose_name_plural': 'collection-species', + }, + ), + migrations.AlterUniqueTogether( + name='collectionspecies', + unique_together=set([('collection', 'species')]), + ), + migrations.AlterField( + model_name='collectionspecies', + name='collection', + field=models.ForeignKey(to='collections_ccdb.Collection', related_name='collection_species'), + ), + migrations.AlterField( + model_name='collectionspecies', + name='species', + field=models.ForeignKey(to='species.Species', related_name='collection_species'), + ), + migrations.AlterField( + model_name='trapspecies', + name='collection_trap', + field=models.ForeignKey(to='collections_ccdb.CollectionTrap', related_name='trap_species'), + ), + migrations.AlterField( + model_name='trapspecies', + name='species', + field=models.ForeignKey(to='species.Species', related_name='trap_species'), + ), ] diff --git a/ccdb/species/migrations/0004_DATA_initial.py b/ccdb/species/migrations/0002_DATA_initial.py similarity index 93% rename from ccdb/species/migrations/0004_DATA_initial.py rename to ccdb/species/migrations/0002_DATA_initial.py index f4d3a11..ebd2548 100644 --- a/ccdb/species/migrations/0004_DATA_initial.py +++ b/ccdb/species/migrations/0002_DATA_initial.py @@ -27,12 +27,14 @@ class Migration(migrations.Migration): else: print('species', r[0:], form.errors.as_data()) + def rollback(apps, schema_editor): Species = apps.get_model('species', 'Species') Species.objects.all().delete() dependencies = [ - ('species', '0003_collectionspecies'), + ('species', '0001_initial'), + ('locations', '0002_DATA_initial'), ] operations = [ diff --git a/ccdb/species/migrations/0002_trapspecies.py b/ccdb/species/migrations/0002_trapspecies.py deleted file mode 100644 index b181c95..0000000 --- a/ccdb/species/migrations/0002_trapspecies.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0001_initial'), - ('species', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='TrapSpecies', - fields=[ - ('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)), - ('sex', models.CharField(blank=True, max_length=25)), - ('count', models.IntegerField(blank=True, null=True)), - ('count_estimated', models.BooleanField(default=False)), - ('collection_trap', models.ForeignKey(to='collections_ccdb.CollectionTrap')), - ('species', models.ForeignKey(to='species.Species')), - ], - options={ - 'verbose_name_plural': 'trap-species', - }, - ), - ] diff --git a/ccdb/species/migrations/0003_collectionspecies.py b/ccdb/species/migrations/0003_collectionspecies.py deleted file mode 100644 index 09145a5..0000000 --- a/ccdb/species/migrations/0003_collectionspecies.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('collections_ccdb', '0001_initial'), - ('species', '0002_trapspecies'), - ] - - operations = [ - migrations.CreateModel( - name='CollectionSpecies', - fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), - ('sex', models.CharField(blank=True, max_length=25)), - ('count', models.IntegerField(null=True, blank=True)), - ('count_estimated', models.BooleanField(default=False)), - ('collection', models.ForeignKey(to='collections_ccdb.Collection')), - ('species', models.ForeignKey(to='species.Species')), - ], - options={ - 'verbose_name_plural': 'collection-species', - }, - ), - migrations.AlterUniqueTogether( - name='collectionspecies', - unique_together=set([('collection', 'species')]), - ), - ] diff --git a/ccdb/species/migrations/0005_DATA_species_collection.py b/ccdb/species/migrations/0005_DATA_species_collection.py deleted file mode 100644 index 487b7c4..0000000 --- a/ccdb/species/migrations/0005_DATA_species_collection.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.db import migrations -from django.forms import modelform_factory - -from ccdb.utils.data import get_data_sources - - -class Migration(migrations.Migration): - def migrate(apps, schema_editor): - sources = get_data_sources() - if not sources: - return - - c = sources['db0'] - - CollectionSpecies = apps.get_model('species', 'CollectionSpecies') - - CollectionSpecies.objects.all().delete() - - CollectionSpeciesForm = modelform_factory(CollectionSpecies, fields='__all__') - - for r in c.execute('SELECT * FROM tbl_hash_collection_species;'): - form = CollectionSpeciesForm(dict(collection=r[0], species=r[1], sex=r[2], - count=r[3], count_estimated=r[4])) - if form.is_valid(): - # No PK in Andre's file - form.save() - else: - print('collection species', r[0:], form.errors.as_data()) - - def rollback(apps, schema_editor): - CollectionSpecies = apps.get_model('species', 'CollectionSpecies') - CollectionSpecies.objects.all().delete() - - dependencies = [ - ('species', '0004_DATA_initial'), - ('collections_ccdb', '0005_DATA_initial'), - ] - - operations = [ - migrations.RunPython(migrate, rollback), - ] diff --git a/ccdb/species/migrations/0006_set_labels.py b/ccdb/species/migrations/0006_set_labels.py deleted file mode 100644 index e36c92d..0000000 --- a/ccdb/species/migrations/0006_set_labels.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('species', '0005_DATA_species_collection'), - ] - - operations = [ - migrations.AlterField( - model_name='collectionspecies', - name='collection', - field=models.ForeignKey(related_name='collection_species', to='collections_ccdb.Collection'), - ), - migrations.AlterField( - model_name='collectionspecies', - name='species', - field=models.ForeignKey(related_name='collection_species', to='species.Species'), - ), - migrations.AlterField( - model_name='trapspecies', - name='collection_trap', - field=models.ForeignKey(related_name='trap_species', to='collections_ccdb.CollectionTrap'), - ), - migrations.AlterField( - model_name='trapspecies', - name='species', - field=models.ForeignKey(related_name='trap_species', to='species.Species'), - ), - ] diff --git a/config/settings/base.py b/config/settings/base.py index a11a2f6..ba9d175 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -16,17 +16,13 @@ DJANGO_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', + 'django.contrib.sites', # Need this for djoser 'django.contrib.messages', 'django.contrib.staticfiles', 'grappelli', 'django.contrib.admin', ) THIRD_PARTY_APPS = ( - 'crispy_forms', - 'allauth', - 'allauth.account', - 'bootstrap3', - 'django_tables2', 'rest_framework', 'rest_framework.authtoken', 'corsheaders', @@ -242,3 +238,5 @@ REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'drf_ember_pagination.EmberPageNumberPagination', 'PAGE_SIZE': 100, } + +SITE_ID = 1