commit
040fe41285
21 changed files with 674 additions and 143 deletions
ccdb
collections_ccdb
locations
processing
species
utils/management/commands
config/settings
misc
1
ccdb/collections_ccdb/__init__.py
Normal file
1
ccdb/collections_ccdb/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
default_app_config = 'ccdb.collections_ccdb.apps.CollectionsAppConfig'
|
60
ccdb/collections_ccdb/admin.py
Normal file
60
ccdb/collections_ccdb/admin.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import CollectionType, CollectionMethod, Flaw, ADFGPermit, \
|
||||
DatasheetAttachment, CollectionTrap
|
||||
|
||||
|
||||
class CollectionTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'code', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'sort_order')
|
||||
|
||||
|
||||
class CollectionMethodAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'code', 'collection_method_class', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code', 'collection_method_class')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'collection_method_class', 'sort_order')
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'description', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'description')
|
||||
|
||||
|
||||
class ADFGPermitAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name',)
|
||||
list_per_page = 25
|
||||
fields = ('name', 'sort_order')
|
||||
|
||||
|
||||
class DatasheetAttachmentAdmin(admin.ModelAdmin):
|
||||
list_display = ('collection', 'datasheet')
|
||||
list_display_links = ('datasheet',)
|
||||
list_per_page = 25
|
||||
fields = ('collection', 'datasheet')
|
||||
|
||||
|
||||
class CollectionTrapAdmin(admin.ModelAdmin):
|
||||
list_display = ('collection', 'number_of_traps', 'date_opened',
|
||||
'time_opened', 'date_closed', 'time_closed')
|
||||
list_display_links = ('number_of_traps',)
|
||||
list_per_page = 25
|
||||
fields = ('collection', 'number_of_traps', 'date_opened',
|
||||
'time_opened', 'date_closed', 'time_closed')
|
||||
|
||||
|
||||
admin.site.register(CollectionType, CollectionTypeAdmin)
|
||||
admin.site.register(CollectionMethod, CollectionMethodAdmin)
|
||||
admin.site.register(Flaw, FlawAdmin)
|
||||
admin.site.register(ADFGPermit, ADFGPermitAdmin)
|
||||
admin.site.register(DatasheetAttachment, DatasheetAttachmentAdmin)
|
||||
admin.site.register(CollectionTrap, CollectionTrapAdmin)
|
7
ccdb/collections_ccdb/apps.py
Normal file
7
ccdb/collections_ccdb/apps.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
# This is needed because 'collections' is part of the Python Std Lib
|
||||
class CollectionsAppConfig(AppConfig):
|
||||
name = 'ccdb.collections_ccdb'
|
||||
verbose_name = 'Collections'
|
158
ccdb/collections_ccdb/migrations/0001_initial.py
Normal file
158
ccdb/collections_ccdb/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,158 @@
|
|||
# -*- 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'),
|
||||
('processing', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ADFGPermit',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', 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')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
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)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CollectionMethod',
|
||||
fields=[
|
||||
('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)),
|
||||
('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')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CollectionTrap',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)),
|
||||
('number_of_traps', models.IntegerField()),
|
||||
('date_opened', models.DateField()),
|
||||
('time_opened', models.TimeField()),
|
||||
('date_closed', models.DateField()),
|
||||
('time_closed', models.TimeField()),
|
||||
('collection', models.ForeignKey(to='collections_ccdb.Collection')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CollectionType',
|
||||
fields=[
|
||||
('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(editable=False, populate_from='name')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
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')),
|
||||
('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)),
|
||||
('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')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='collectiontype',
|
||||
unique_together=set([('name', 'code')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='collectionmethod',
|
||||
unique_together=set([('name', 'code')]),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='collection_method',
|
||||
field=models.ForeignKey(to='collections_ccdb.CollectionMethod'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='collection_type',
|
||||
field=models.ForeignKey(to='collections_ccdb.CollectionType'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='flaw',
|
||||
field=models.ForeignKey(to='collections_ccdb.Flaw', blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='process_type',
|
||||
field=models.ForeignKey(to='processing.ProcessType', blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='project',
|
||||
field=models.ForeignKey(to='projects.Project'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='reagent',
|
||||
field=models.ForeignKey(to='processing.Reagent', blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='storage_location',
|
||||
field=models.ForeignKey(to='locations.StorageLocation', blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='study_location',
|
||||
field=models.ForeignKey(to='locations.StudyLocation'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='collectiontrap',
|
||||
unique_together=set([('collection', 'date_opened', 'time_opened', 'date_closed', 'time_closed')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='collection',
|
||||
unique_together=set([('project', 'study_location', 'collection_type', 'collection_start_date', 'collection_end_date', 'collection_method')]),
|
||||
),
|
||||
]
|
0
ccdb/collections_ccdb/migrations/__init__.py
Normal file
0
ccdb/collections_ccdb/migrations/__init__.py
Normal file
105
ccdb/collections_ccdb/models.py
Normal file
105
ccdb/collections_ccdb/models.py
Normal file
|
@ -0,0 +1,105 @@
|
|||
from django.db import models
|
||||
|
||||
from autoslug import AutoSlugField
|
||||
|
||||
|
||||
class CollectionType(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
code = models.CharField(max_length=10, blank=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'code')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class CollectionMethod(models.Model):
|
||||
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(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'code')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Flaw(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
description = models.CharField(max_length=255, blank=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class ADFGPermit(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Collection(models.Model):
|
||||
project = models.ForeignKey('projects.Project')
|
||||
study_location = models.ForeignKey('locations.StudyLocation')
|
||||
collection_type = models.ForeignKey(CollectionType)
|
||||
collection_method = models.ForeignKey(CollectionMethod)
|
||||
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)
|
||||
storage_location = models.ForeignKey('locations.StorageLocation', blank=True, null=True)
|
||||
specimen_state = models.CharField(max_length=50, blank=True)
|
||||
process_type = models.ForeignKey('processing.ProcessType', blank=True, null=True)
|
||||
reagent = models.ForeignKey('processing.Reagent', blank=True, null=True)
|
||||
adfg_permit = models.ForeignKey(ADFGPermit, blank=True, null=True)
|
||||
flaw = models.ForeignKey(Flaw, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{} {} {} {} {} {}".format(self.project, self.study_location,
|
||||
self.collection_start_date, self.collection_end_date,
|
||||
self.collection_type, self.collection_method)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('project', 'study_location', 'collection_type',
|
||||
'collection_start_date', 'collection_end_date', 'collection_method')
|
||||
|
||||
|
||||
class DatasheetAttachment(models.Model):
|
||||
collection = models.ForeignKey(Collection)
|
||||
datasheet = models.FileField("Datasheet",
|
||||
upload_to='collections/datasheets/%Y/%m/%d')
|
||||
|
||||
|
||||
class CollectionTrap(models.Model):
|
||||
collection = models.ForeignKey(Collection)
|
||||
number_of_traps = models.IntegerField()
|
||||
date_opened = models.DateField()
|
||||
time_opened = models.TimeField()
|
||||
date_closed = models.DateField()
|
||||
time_closed = models.TimeField()
|
||||
|
||||
def __str__(self):
|
||||
return "{collection} {number_of_traps} {date_opened} {date_closed}".format(self)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('collection', 'date_opened', 'time_opened', 'date_closed', 'time_closed')
|
23
ccdb/locations/migrations/0002_remove_site_fk_dupes.py
Normal file
23
ccdb/locations/migrations/0002_remove_site_fk_dupes.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# -*- 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'),
|
||||
),
|
||||
]
|
|
@ -33,7 +33,6 @@ class Site(models.Model):
|
|||
|
||||
|
||||
class MunicipalLocation(models.Model):
|
||||
site = models.ForeignKey(Site)
|
||||
name = models.CharField(max_length=100)
|
||||
code = models.CharField(max_length=10, blank=True)
|
||||
municipal_location_type = models.CharField(max_length=50, blank=True)
|
||||
|
@ -49,7 +48,7 @@ class MunicipalLocation(models.Model):
|
|||
|
||||
|
||||
class StudyLocation(models.Model):
|
||||
site = models.ForeignKey(Site, blank=True, null=True)
|
||||
site = models.ForeignKey(Site)
|
||||
name = models.CharField(max_length=100)
|
||||
code = models.CharField(max_length=10, blank=True)
|
||||
study_location_type = models.CharField(max_length=50, blank=True)
|
||||
|
|
0
ccdb/processing/__init__.py
Normal file
0
ccdb/processing/__init__.py
Normal file
32
ccdb/processing/admin.py
Normal file
32
ccdb/processing/admin.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import ProcessType, Reagent, Flaw
|
||||
|
||||
|
||||
class ProcessTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'code', 'description', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'description', 'sort_order')
|
||||
|
||||
|
||||
class ReagentAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'code', 'reagent_class', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code', 'reagent_class')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'reagent_class', 'sort_order')
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'description', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'description')
|
||||
|
||||
|
||||
admin.site.register(ProcessType, ProcessTypeAdmin)
|
||||
admin.site.register(Reagent, ReagentAdmin)
|
||||
admin.site.register(Flaw, FlawAdmin)
|
92
ccdb/processing/migrations/0001_initial.py
Normal file
92
ccdb/processing/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
# -*- 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'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Flaw',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('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.CreateModel(
|
||||
name='Processing',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('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)),
|
||||
('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)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ProcessType',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('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)),
|
||||
('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Reagent',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('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)),
|
||||
('slug', autoslug.fields.AutoSlugField(populate_from='name', editable=False)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='reagent',
|
||||
unique_together=set([('name', 'code')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='processtype',
|
||||
unique_together=set([('name', 'code')]),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='processing',
|
||||
name='process_type',
|
||||
field=models.ForeignKey(to='processing.ProcessType'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='processing',
|
||||
name='reagent',
|
||||
field=models.ForeignKey(to='processing.Reagent', blank=True, null=True),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='processing',
|
||||
unique_together=set([('process_type', 'container', 'container_label', 'process_date', 'process_time', 'reagent')]),
|
||||
),
|
||||
]
|
0
ccdb/processing/migrations/__init__.py
Normal file
0
ccdb/processing/migrations/__init__.py
Normal file
66
ccdb/processing/models.py
Normal file
66
ccdb/processing/models.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
from django.db import models
|
||||
|
||||
from autoslug import AutoSlugField
|
||||
|
||||
|
||||
class ProcessType(models.Model):
|
||||
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(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'code')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Reagent(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
code = models.CharField(max_length=10, blank=True)
|
||||
reagent_class = models.CharField(max_length=50, blank=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'code')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Flaw(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
description = models.CharField(max_length=255, blank=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Processing(models.Model):
|
||||
process_type = models.ForeignKey(ProcessType)
|
||||
container = models.ForeignKey('misc.Container')
|
||||
container_label = models.CharField(max_length=50)
|
||||
process_date = models.DateField(blank=True, null=True)
|
||||
process_time = models.TimeField(blank=True, null=True)
|
||||
reagent = models.ForeignKey(Reagent, blank=True, null=True)
|
||||
reagent_volume = models.FloatField(blank=True, null=True)
|
||||
measurement_unit = models.ForeignKey('misc.MeasurementUnit', blank=True, null=True)
|
||||
minutes_in_reagent = models.IntegerField(blank=True, null=True)
|
||||
flaw = models.ForeignKey(Flaw, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{process_date} {process_type} {container_label}".format(**self)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('process_type', 'container', 'container_label',
|
||||
'process_date', 'process_time', 'reagent')
|
0
ccdb/species/__init__.py
Normal file
0
ccdb/species/__init__.py
Normal file
14
ccdb/species/admin.py
Normal file
14
ccdb/species/admin.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Species
|
||||
|
||||
|
||||
class SpeciesAdmin(admin.ModelAdmin):
|
||||
list_display = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
|
||||
list_display_links = ('common_name',)
|
||||
search_fields = ('common_name', 'genus', 'species', 'parasite')
|
||||
list_per_page = 25
|
||||
fields = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
|
||||
|
||||
|
||||
admin.site.register(Species, SpeciesAdmin)
|
34
ccdb/species/migrations/0001_initial.py
Normal file
34
ccdb/species/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# -*- 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='Species',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
|
||||
('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')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
'verbose_name_plural': 'species',
|
||||
},
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='species',
|
||||
unique_together=set([('common_name', 'species')]),
|
||||
),
|
||||
]
|
0
ccdb/species/migrations/__init__.py
Normal file
0
ccdb/species/migrations/__init__.py
Normal file
20
ccdb/species/models.py
Normal file
20
ccdb/species/models.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from django.db import models
|
||||
|
||||
from autoslug import AutoSlugField
|
||||
|
||||
|
||||
class Species(models.Model):
|
||||
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 = AutoSlugField(populate_from='common_name')
|
||||
|
||||
def __str__(self):
|
||||
return self.common_name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('common_name', 'species')
|
||||
ordering = ['sort_order']
|
||||
verbose_name_plural = 'species'
|
|
@ -12,6 +12,10 @@ from ccdb.misc.models import MeasurementUnit, MeasurementType, Container, \
|
|||
Material, Color
|
||||
from ccdb.locations.models import Region, Site, MunicipalLocation, \
|
||||
StudyLocation, StorageLocation
|
||||
from ccdb.species.models import Species
|
||||
from ccdb.processing.models import ProcessType, Reagent, Flaw, Processing
|
||||
from ccdb.collections_ccdb.models import CollectionType, CollectionMethod, \
|
||||
Flaw, ADFGPermit, Collection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -23,7 +27,7 @@ class Command(BaseCommand):
|
|||
def handle(self, **options):
|
||||
_fetch_data(options['manifest_url'], self.stdout.write)
|
||||
self.stdout.write('Fetched data')
|
||||
_import_data()
|
||||
_import_admin_data()
|
||||
self.stdout.write('Imported data')
|
||||
|
||||
|
||||
|
@ -43,7 +47,7 @@ def _fetch_data(url, write):
|
|||
out_file.write(chunk)
|
||||
|
||||
|
||||
def _import_data():
|
||||
def _import_admin_data():
|
||||
c = setup_sqlite()
|
||||
if c:
|
||||
# Projects
|
||||
|
@ -125,7 +129,7 @@ def _import_data():
|
|||
|
||||
# Municipal Locations
|
||||
for r in c.execute('SELECT * FROM tbl_lu_municipal_locations;'):
|
||||
ml = MunicipalLocation(site_id=r[0], id=r[1], name=r[2], code=r[3],
|
||||
ml = MunicipalLocation(id=r[1], name=r[2], code=r[3],
|
||||
municipal_location_type=r[4], description=r[5], sort_order=r[6])
|
||||
ml.save()
|
||||
|
||||
|
@ -151,3 +155,54 @@ def _import_data():
|
|||
room=r[3], freezer=r[4], temp_c=r[5], code=code,
|
||||
description=r[6], sort_order=r[7])
|
||||
sl.save()
|
||||
|
||||
# Species
|
||||
for r in c.execute('SELECT * FROM tbl_lu_species;'):
|
||||
s = Species(id=r[0], common_name=r[1], genus=r[2], species=r[3],
|
||||
parasite=r[4], sort_order=r[5])
|
||||
s.save()
|
||||
|
||||
# Processing Type
|
||||
for r in c.execute('SELECT * FROM tbl_lu_process_types;'):
|
||||
pt = ProcessType(id=r[0], name=r[1], code=r[2], description=r[3],
|
||||
sort_order=r[4])
|
||||
pt.save()
|
||||
|
||||
# Reagent
|
||||
for r in c.execute('SELECT * FROM tbl_lu_reagents;'):
|
||||
rg = Reagent(id=r[0], name=r[1], code=r[2], reagent_class=r[3],
|
||||
sort_order=r[4])
|
||||
rg.save()
|
||||
|
||||
# Collection Type
|
||||
for r in c.execute('SELECT * FROM tbl_lu_collection_types;'):
|
||||
ct = CollectionType(id=r[0], name=r[1], code=r[2], sort_order=r[3])
|
||||
ct.save()
|
||||
|
||||
# Collection Method
|
||||
for r in c.execute('SELECT * FROM tbl_lu_collection_methods;'):
|
||||
cm = CollectionMethod(id=r[0], name=r[1], code=r[2],
|
||||
collection_method_class=r[3], sort_order=r[4])
|
||||
cm.save()
|
||||
|
||||
# Collection
|
||||
for r in c.execute('''
|
||||
SELECT *,
|
||||
collection_start_date AS "collection_start_date [dtdt]",
|
||||
collection_start_time AS "collection_start_time [dtdt]",
|
||||
collection_end_date AS "collection_end_date [dtdt]",
|
||||
collection_end_time AS "collection_end_time [dtdt]"
|
||||
FROM tbl_collections;
|
||||
'''):
|
||||
if r[14] is not '':
|
||||
permit, _ = ADFGPermit.objects.get_or_create(name=r[14])
|
||||
else:
|
||||
permit = None
|
||||
col = Collection(project_id=r[0], id=r[1], study_location_id=r[2],
|
||||
collection_type_id=r[3], collection_method_id=r[4],
|
||||
number_of_traps=r[5], collection_start_date=r[17],
|
||||
collection_start_time=r[18], collection_end_date=r[19],
|
||||
collection_end_time=r[20], storage_location_id=r[10],
|
||||
specimen_state=r[11], process_type_id=r[12], reagent_id=r[13],
|
||||
adfg_permit=permit)
|
||||
col.save()
|
||||
|
|
|
@ -42,6 +42,9 @@ LOCAL_APPS = (
|
|||
'ccdb.projects',
|
||||
'ccdb.misc',
|
||||
'ccdb.locations',
|
||||
'ccdb.species',
|
||||
'ccdb.collections_ccdb',
|
||||
'ccdb.processing',
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
|
|
138
misc/existing.py
138
misc/existing.py
|
@ -74,31 +74,6 @@ class TblBioReplicates(models.Model):
|
|||
db_table = 'tbl_Bio_Replicates'
|
||||
|
||||
|
||||
class TblCollections(models.Model):
|
||||
projectid = models.ForeignKey('TblLuProjects', db_column='ProjectID') # Field name made lowercase.
|
||||
collectionid = models.AutoField(db_column='CollectionID', primary_key=True) # Field name made lowercase.
|
||||
study_locationid = models.ForeignKey('TblLuStudyLocations', db_column='Study_LocationID') # Field name made lowercase.
|
||||
collection_typeid = models.ForeignKey('TblLuCollectionTypes', db_column='Collection_TypeID') # Field name made lowercase.
|
||||
collection_methodid = models.ForeignKey('TblLuCollectionMethods', db_column='Collection_MethodID') # Field name made lowercase.
|
||||
number_of_traps = models.IntegerField(db_column='Number_Of_Traps', blank=True, null=True) # Field name made lowercase.
|
||||
collection_start_date = models.DateField(db_column='Collection_Start_Date', blank=True, null=True) # Field name made lowercase.
|
||||
collection_start_time = models.TimeField(db_column='Collection_Start_Time', blank=True, null=True) # Field name made lowercase.
|
||||
collection_end_date = models.DateField(db_column='Collection_End_Date', blank=True, null=True) # Field name made lowercase.
|
||||
collection_end_time = models.TimeField(db_column='Collection_End_Time', blank=True, null=True) # Field name made lowercase.
|
||||
storage_locationid = models.ForeignKey('TblLuStorageLocations', db_column='Storage_LocationID', blank=True, null=True) # Field name made lowercase.
|
||||
specimen_state = models.CharField(db_column='Specimen_State', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
process_typeid = models.ForeignKey('TblLuProcessTypes', db_column='Process_TypeID', blank=True, null=True) # Field name made lowercase.
|
||||
reagentid = models.ForeignKey('TblLuReagents', db_column='ReagentID', blank=True, null=True) # Field name made lowercase.
|
||||
adfg_permit = models.CharField(db_column='ADFG_Permit', max_length=25, blank=True, null=True) # Field name made lowercase.
|
||||
link_to_datasheets = models.CharField(db_column='Link_To_Datasheets', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
flawid = models.ForeignKey('TblLuRecordFlaws', db_column='FlawID', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_Collections'
|
||||
unique_together = (('ProjectID', 'Study_LocationID', 'Collection_TypeID', 'Collection_Start_Date', 'Collection_End_Date', 'Collection_MethodID'),)
|
||||
|
||||
|
||||
class TblComments(models.Model):
|
||||
record_typeid = models.ForeignKey('TblLuRecordTypes', db_column='Record_TypeID') # Field name made lowercase.
|
||||
foreign_key = models.AutoField(db_column='Foreign_Key') # Field name made lowercase.
|
||||
|
@ -240,22 +215,6 @@ class TblHashCollectionSpecies(models.Model):
|
|||
unique_together = (('CollectionID', 'SpeciesID'),)
|
||||
|
||||
|
||||
class TblHashCollectionTraps(models.Model):
|
||||
colltrapid = models.AutoField(db_column='CollTrapID', primary_key=True) # Field name made lowercase.
|
||||
collectionid = models.ForeignKey(TblCollections, db_column='CollectionID') # Field name made lowercase.
|
||||
number_of_traps = models.IntegerField(db_column='Number_Of_Traps') # Field name made lowercase.
|
||||
date_opened = models.DateField(db_column='Date_Opened') # Field name made lowercase.
|
||||
time_opened = models.TimeField(db_column='Time_Opened') # Field name made lowercase.
|
||||
date_closed = models.DateField(db_column='Date_Closed') # Field name made lowercase.
|
||||
time_closed = models.TimeField(db_column='Time_Closed') # Field name made lowercase.
|
||||
reference = models.CharField(db_column='Reference', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_HASH_Collection_Traps'
|
||||
unique_together = (('CollectionID', 'Date_Opened', 'Time_Opened', 'Date_Closed', 'Time_Closed'),)
|
||||
|
||||
|
||||
class TblHashPeopleSets(models.Model):
|
||||
peoplesetid = models.AutoField(db_column='PeopleSetID', primary_key=True) # Field name made lowercase.
|
||||
record_typeid = models.ForeignKey('TblLuRecordTypes', db_column='Record_TypeID') # Field name made lowercase.
|
||||
|
@ -318,31 +277,6 @@ class TblLuBioMolecules(models.Model):
|
|||
unique_together = (('BioMolecule', 'BioMolecule_Code'),)
|
||||
|
||||
|
||||
class TblLuCollectionMethods(models.Model):
|
||||
collection_methodid = models.AutoField(db_column='Collection_MethodID', primary_key=True) # Field name made lowercase.
|
||||
collection_method = models.CharField(db_column='Collection_Method', max_length=100) # Field name made lowercase.
|
||||
collection_method_code = models.CharField(db_column='Collection_Method_Code', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
collection_method_class = models.CharField(db_column='Collection_Method_Class', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Collection_Methods'
|
||||
unique_together = (('Collection_Method', 'Collection_Method_Code'),)
|
||||
|
||||
|
||||
class TblLuCollectionTypes(models.Model):
|
||||
collection_typeid = models.AutoField(db_column='Collection_TypeID', primary_key=True) # Field name made lowercase.
|
||||
collection_type = models.CharField(db_column='Collection_Type', max_length=100) # Field name made lowercase.
|
||||
collection_type_code = models.CharField(db_column='Collection_Type_Code', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Collection_Types'
|
||||
unique_together = (('Collection_Type', 'Collection_Type_Code'),)
|
||||
|
||||
|
||||
class TblLuCommentTypes(models.Model):
|
||||
comment_typeid = models.AutoField(db_column='Comment_TypeID', primary_key=True) # Field name made lowercase.
|
||||
comment_type = models.CharField(db_column='Comment_Type', max_length=100) # Field name made lowercase.
|
||||
|
@ -399,45 +333,6 @@ class TblLuPeople(models.Model):
|
|||
unique_together = (('First_Name', 'Middle_Initial', 'Last_Name'),)
|
||||
|
||||
|
||||
class TblLuProcessTypes(models.Model):
|
||||
process_typeid = models.AutoField(db_column='Process_TypeID', primary_key=True) # Field name made lowercase.
|
||||
process_type = models.CharField(db_column='Process_Type', max_length=100) # Field name made lowercase.
|
||||
process_type_code = models.CharField(db_column='Process_Type_Code', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
ptype_short_description = models.CharField(db_column='PType_Short_Description', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Process_Types'
|
||||
unique_together = (('Process_Type', 'Process_Type_Code'),)
|
||||
|
||||
|
||||
class TblLuReagents(models.Model):
|
||||
reagentid = models.AutoField(db_column='ReagentID', primary_key=True) # Field name made lowercase.
|
||||
reagent = models.CharField(db_column='Reagent', max_length=100) # Field name made lowercase.
|
||||
reagent_code = models.CharField(db_column='Reagent_Code', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
reagent_class = models.CharField(db_column='Reagent_Class', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Reagents'
|
||||
unique_together = (('Reagent', 'Reagent_Code'),)
|
||||
|
||||
|
||||
class TblLuRecordFlaws(models.Model):
|
||||
flawid = models.AutoField(db_column='FlawID', primary_key=True) # Field name made lowercase.
|
||||
record_typeid = models.ForeignKey('TblLuRecordTypes', db_column='Record_TypeID') # Field name made lowercase.
|
||||
flaw = models.CharField(db_column='Flaw', max_length=200) # Field name made lowercase.
|
||||
flaw_short_description = models.CharField(db_column='Flaw_Short_Description', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Record_Flaws'
|
||||
unique_together = (('Record_TypeID', 'Flaw'),)
|
||||
|
||||
|
||||
class TblLuRecordTypes(models.Model):
|
||||
record_typeid = models.AutoField(db_column='Record_TypeID', primary_key=True) # Field name made lowercase.
|
||||
record_type = models.CharField(db_column='Record_Type', unique=True, max_length=50) # Field name made lowercase.
|
||||
|
@ -461,20 +356,6 @@ class TblLuSampleTypes(models.Model):
|
|||
unique_together = (('Sample_Type', 'Sample_Type_Code'),)
|
||||
|
||||
|
||||
class TblLuSpecies(models.Model):
|
||||
speciesid = models.AutoField(db_column='SpeciesID', primary_key=True) # Field name made lowercase.
|
||||
common_name = models.CharField(db_column='Common_Name', max_length=100) # Field name made lowercase.
|
||||
genus = models.CharField(db_column='Genus', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
species = models.CharField(db_column='Species', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
parasite = models.BooleanField(db_column='Parasite') # Field name made lowercase.
|
||||
sort_order = models.IntegerField(db_column='Sort_Order', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_LU_Species'
|
||||
unique_together = (('Common_Name', 'Species'),)
|
||||
|
||||
|
||||
class TblLuTreatmentTypes(models.Model):
|
||||
treatment_typeid = models.AutoField(db_column='Treatment_TypeID', primary_key=True) # Field name made lowercase.
|
||||
experimentid = models.ForeignKey(TblLuExperiments, db_column='ExperimentID', blank=True, null=True) # Field name made lowercase.
|
||||
|
@ -506,25 +387,6 @@ class TblLuUsers(models.Model):
|
|||
db_table = 'tbl_LU_Users'
|
||||
|
||||
|
||||
class TblProcessing(models.Model):
|
||||
processid = models.AutoField(db_column='ProcessID', primary_key=True) # Field name made lowercase.
|
||||
process_typeid = models.ForeignKey(TblLuProcessTypes, db_column='Process_TypeID') # Field name made lowercase.
|
||||
containerid = models.ForeignKey(TblLuContainers, db_column='ContainerID') # Field name made lowercase.
|
||||
container_label = models.CharField(db_column='Container_Label', max_length=50) # Field name made lowercase.
|
||||
process_date = models.DateField(db_column='Process_Date', blank=True, null=True) # Field name made lowercase.
|
||||
process_time = models.TimeField(db_column='Process_Time', blank=True, null=True) # Field name made lowercase.
|
||||
reagentid = models.ForeignKey(TblLuReagents, db_column='ReagentID', blank=True, null=True) # Field name made lowercase.
|
||||
reagent_volume = models.FloatField(db_column='Reagent_Volume', blank=True, null=True) # Field name made lowercase.
|
||||
measurement_unitid = models.ForeignKey(TblLuMeasurementUnits, db_column='Measurement_UnitID', blank=True, null=True) # Field name made lowercase.
|
||||
time_in_reagent = models.CharField(db_column='Time_in_Reagent', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
flawid = models.ForeignKey(TblLuRecordFlaws, db_column='FlawID', blank=True, null=True) # Field name made lowercase.
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = 'tbl_Processing'
|
||||
unique_together = (('Process_TypeID', 'ContainerID', 'Container_Label', 'Process_Date', 'Process_Time', 'ReagentID'),)
|
||||
|
||||
|
||||
class TblSamples(models.Model):
|
||||
trrepid = models.ForeignKey('TblTreatmentReplicates', db_column='TrRepID') # Field name made lowercase.
|
||||
sampleid = models.AutoField(db_column='SampleID', primary_key=True) # Field name made lowercase.
|
||||
|
|
Loading…
Add table
Reference in a new issue