Treatment Type
This commit is contained in:
parent
55e08501d5
commit
ab1d605c95
6 changed files with 77 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Flaw, Experiment, ProtocolAttachment
|
||||
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
|
@ -27,6 +27,18 @@ class ProtocolAttachmentAdmin(admin.ModelAdmin):
|
|||
fields = ('experiment', 'protocol')
|
||||
|
||||
|
||||
class TreatmentTypeAdmin(admin.ModelAdmin):
|
||||
list_display = ('experiment', 'name', 'code', 'treatment_type',
|
||||
'placement', 'description', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('experiment', 'name', 'code', 'treatment_type',
|
||||
'placement', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('experiment', 'name', 'code', 'treatment_type', 'placement',
|
||||
'description', 'sort_order')
|
||||
|
||||
|
||||
admin.site.register(Flaw, FlawAdmin)
|
||||
admin.site.register(Experiment, ExperimentAdmin)
|
||||
admin.site.register(ProtocolAttachment, ProtocolAttachmentAdmin)
|
||||
admin.site.register(TreatmentType, TreatmentTypeAdmin)
|
||||
|
|
|
@ -19,6 +19,7 @@ class Migration(migrations.Migration):
|
|||
('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={
|
||||
'ordering': ['sort_order'],
|
||||
|
|
36
ccdb/experiments/migrations/0002_treatment_type.py
Normal file
36
ccdb/experiments/migrations/0002_treatment_type.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# -*- 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')]),
|
||||
),
|
||||
]
|
|
@ -22,6 +22,7 @@ class Experiment(models.Model):
|
|||
description = models.CharField(max_length=255, blank=True)
|
||||
flaw = models.ForeignKey(Flaw, blank=True, null=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -37,3 +38,21 @@ class ProtocolAttachment(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.protocol
|
||||
|
||||
|
||||
class TreatmentType(models.Model):
|
||||
experiment = models.ForeignKey(Experiment, blank=True, null=True)
|
||||
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(blank=True, null=True)
|
||||
slug = AutoSlugField(populate_from='name')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('experiment', 'name')
|
||||
ordering = ['sort_order']
|
||||
|
|
|
@ -16,7 +16,8 @@ from ccdb.species.models import Species, CollectionSpecies
|
|||
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
|
||||
from ccdb.experiments.models import Flaw, Experiment, ProtocolAttachment, \
|
||||
TreatmentType
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -223,3 +224,9 @@ def _import_admin_data():
|
|||
e = Experiment(id=r[0], name=r[1], code=r[2],
|
||||
description=r[3], sort_order=r[6])
|
||||
e.save()
|
||||
|
||||
# Treatment Type
|
||||
for r in c.execute('SELECT * FROM tbl_lu_treatment_types;'):
|
||||
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()
|
||||
|
|
|
@ -315,22 +315,6 @@ class TblLuSampleTypes(models.Model):
|
|||
unique_together = (('Sample_Type', 'Sample_Type_Code'),)
|
||||
|
||||
|
||||
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.
|
||||
treatment = models.CharField(db_column='Treatment', max_length=200) # Field name made lowercase.
|
||||
treatment_code = models.CharField(db_column='Treatment_Code', max_length=25, blank=True, null=True) # Field name made lowercase.
|
||||
treatment_type = models.CharField(db_column='Treatment_Type', max_length=50, blank=True, null=True) # Field name made lowercase.
|
||||
placement = models.CharField(db_column='Placement', max_length=25, blank=True, null=True) # Field name made lowercase.
|
||||
treatment_short_description = models.CharField(db_column='Treatment_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_Treatment_Types'
|
||||
unique_together = (('ExperimentID', 'Treatment'),)
|
||||
|
||||
|
||||
class TblLuUsers(models.Model):
|
||||
userid = models.AutoField(db_column='UserID', primary_key=True) # Field name made lowercase.
|
||||
first_name = models.CharField(db_column='First_Name', max_length=50) # Field name made lowercase.
|
||||
|
|
Loading…
Add table
Reference in a new issue