Treatment
This commit is contained in:
parent
ab1d605c95
commit
a8a87f7ddb
5 changed files with 65 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType
|
||||
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \
|
||||
Treatment
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
|
@ -38,7 +39,19 @@ class TreatmentTypeAdmin(admin.ModelAdmin):
|
|||
'description', 'sort_order')
|
||||
|
||||
|
||||
class TreatmentAdmin(admin.ModelAdmin):
|
||||
list_display = ('treatment_type', 'container', 'study_location', 'species',
|
||||
'sex', 'flaw')
|
||||
list_display_links = ('treatment_type',)
|
||||
search_fields = ('treatment_type', 'container', 'study_location', 'species',
|
||||
'sex', 'flaw')
|
||||
list_per_page = 25
|
||||
fields = ('treatment_type', 'container', 'study_location', 'species',
|
||||
'sex', 'flaw')
|
||||
|
||||
|
||||
admin.site.register(Flaw, FlawAdmin)
|
||||
admin.site.register(Experiment, ExperimentAdmin)
|
||||
admin.site.register(ProtocolAttachment, ProtocolAttachmentAdmin)
|
||||
admin.site.register(TreatmentType, TreatmentTypeAdmin)
|
||||
admin.site.register(Treatment, TreatmentAdmin)
|
||||
|
|
29
ccdb/experiments/migrations/0003_treatment.py
Normal file
29
ccdb/experiments/migrations/0003_treatment.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- 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')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -51,8 +51,22 @@ class TreatmentType(models.Model):
|
|||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
return "{} {} {} {}".format(self.experiment, self.name,
|
||||
self.treatment_type, self.placement)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('experiment', 'name')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class Treatment(models.Model):
|
||||
treatment_type = models.ForeignKey(TreatmentType)
|
||||
container = models.ForeignKey('misc.Container', blank=True, null=True)
|
||||
study_location = models.ForeignKey('locations.StudyLocation')
|
||||
species = models.ForeignKey('species.Species')
|
||||
sex = models.CharField(max_length=25)
|
||||
flaw = models.ForeignKey(Flaw, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{} {} {} {}".format(self.treatment_type, self.study_location,
|
||||
self.species, self.sex)
|
||||
|
|
|
@ -17,7 +17,7 @@ from ccdb.processing.models import ProcessType, Reagent, Flaw, Processing
|
|||
from ccdb.collections_ccdb.models import CollectionType, CollectionMethod, \
|
||||
Flaw, ADFGPermit, Collection
|
||||
from ccdb.experiments.models import Flaw, Experiment, ProtocolAttachment, \
|
||||
TreatmentType
|
||||
TreatmentType, Treatment
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -230,3 +230,9 @@ def _import_admin_data():
|
|||
tt = TreatmentType(experiment_id=r[0], id=r[1], name=r[2], code=r[3],
|
||||
treatment_type=r[4], placement=r[5], description=r[6])
|
||||
tt.save()
|
||||
|
||||
# Treatment
|
||||
for r in c.execute('SELECT * FROM tbl_treatments;'):
|
||||
t = Treatment(id=r[0], treatment_type_id=r[1], container_id=r[2],
|
||||
study_location_id=r[3], species_id=r[4], sex=r[5])
|
||||
t.save()
|
||||
|
|
|
@ -362,17 +362,3 @@ class TblTreatmentReplicates(models.Model):
|
|||
managed = False
|
||||
db_table = 'tbl_Treatment_Replicates'
|
||||
unique_together = (('TreatmentID', 'Replicate', 'Setup_Date', 'Setup_Time'),)
|
||||
|
||||
|
||||
class TblTreatments(models.Model):
|
||||
treatmentid = models.AutoField(db_column='TreatmentID', primary_key=True) # Field name made lowercase.
|
||||
treatment_typeid = models.ForeignKey(TblLuTreatmentTypes, db_column='Treatment_TypeID') # Field name made lowercase.
|
||||
containerid = models.ForeignKey(TblLuContainers, db_column='ContainerID', blank=True, null=True) # Field name made lowercase.
|
||||
study_locationid = models.ForeignKey(TblLuStudyLocations, db_column='Study_LocationID') # Field name made lowercase.
|
||||
speciesid = models.ForeignKey(TblLuSpecies, db_column='SpeciesID') # Field name made lowercase.
|
||||
sex = models.CharField(db_column='Sex', max_length=25) # 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_Treatments'
|
||||
|
|
Loading…
Add table
Reference in a new issue