Alive-Dead Count
This commit is contained in:
parent
75cb9a9eea
commit
7c1b12f833
5 changed files with 72 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \
|
||||
Treatment, TreatmentReplicate
|
||||
Treatment, TreatmentReplicate, AliveDeadCount
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
|
@ -61,9 +61,21 @@ class TreatmentReplicateAdmin(admin.ModelAdmin):
|
|||
'setup_sample_size', 'mass_g', 'flaw')
|
||||
|
||||
|
||||
class AliveDeadCountAdmin(admin.ModelAdmin):
|
||||
list_display = ('treatment_replicate', 'status_date', 'status_time',
|
||||
'count_alive', 'count_dead', 'flaw')
|
||||
list_display_links = ('status_date',)
|
||||
search_fields = ('treatment_replicate', 'status_date', 'status_time',
|
||||
'count_alive', 'count_dead', 'flaw')
|
||||
list_per_page = 25
|
||||
fields = ('treatment_replicate', 'status_date', 'status_time',
|
||||
'count_alive', 'count_dead', '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)
|
||||
admin.site.register(TreatmentReplicate, TreatmentReplicateAdmin)
|
||||
admin.site.register(AliveDeadCount, AliveDeadCountAdmin)
|
||||
|
|
26
ccdb/experiments/migrations/0005_alivedeadcount.py
Normal file
26
ccdb/experiments/migrations/0005_alivedeadcount.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- 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')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -87,3 +87,15 @@ class TreatmentReplicate(models.Model):
|
|||
|
||||
class Meta:
|
||||
unique_together = ('treatment', 'name', 'setup_date', 'setup_time')
|
||||
|
||||
|
||||
class AliveDeadCount(models.Model):
|
||||
treatment_replicate = models.ForeignKey(TreatmentReplicate)
|
||||
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(Flaw, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{}".format(self.status_date)
|
||||
|
|
|
@ -18,7 +18,8 @@ from ccdb.processing.models import ProcessType, Reagent, \
|
|||
from ccdb.collections_ccdb.models import CollectionType, CollectionMethod, \
|
||||
Flaw as CollectionFlaw, ADFGPermit, Collection
|
||||
from ccdb.experiments.models import Flaw as ExperimentFlaw, Experiment, \
|
||||
ProtocolAttachment, TreatmentType, Treatment, TreatmentReplicate
|
||||
ProtocolAttachment, TreatmentType, Treatment, TreatmentReplicate, \
|
||||
AliveDeadCount
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -242,12 +243,29 @@ def _import_admin_data():
|
|||
for r in c.execute('''
|
||||
SELECT *, setup_date AS "setup_date [dtdt]"
|
||||
FROM tbl_treatment_replicates tr
|
||||
INNER JOIN tbl_lu_record_flaws f ON f.flawid=tr.flawid;
|
||||
LEFT OUTER JOIN tbl_lu_record_flaws f ON f.flawid=tr.flawid;
|
||||
'''):
|
||||
if r[10] is not '':
|
||||
if r[7]:
|
||||
flaw, _ = ExperimentFlaw.objects.get_or_create(name=r[10])
|
||||
else:
|
||||
flaw = None
|
||||
tr = TreatmentReplicate(treatment_id=r[0], id=r[1], name=r[2],
|
||||
setup_date=r[13], setup_sample_size=r[5], mass_g=r[6], flaw=flaw)
|
||||
tr.save()
|
||||
|
||||
# Alive-Dead Count
|
||||
for r in c.execute('''
|
||||
SELECT *,
|
||||
status_date AS "status_date [dtdt]",
|
||||
status_time AS "status_time [dtdt]"
|
||||
FROM tbl_alive_dead_counts adc
|
||||
LEFT OUTER JOIN tbl_lu_record_flaws f ON f.flawid=adc.flawid;
|
||||
'''):
|
||||
if r[6]:
|
||||
flaw, _ = ExperimentFlaw.objects.get_or_create(name=r[9])
|
||||
else:
|
||||
flaw = None
|
||||
adc = AliveDeadCount(treatment_replicate_id=r[0], id=r[1],
|
||||
status_date=r[12], status_time=r[13], count_alive=r[4],
|
||||
count_dead=r[5], flaw=flaw)
|
||||
adc.save()
|
||||
|
|
|
@ -12,20 +12,6 @@ from __future__ import unicode_literals
|
|||
from django.db import models
|
||||
|
||||
|
||||
class TblAliveDeadCounts(models.Model):
|
||||
trrepid = models.ForeignKey('TblTreatmentReplicates', db_column='TrRepID') # Field name made lowercase.
|
||||
alivedeadcountid = models.AutoField(db_column='AliveDeadCountID', primary_key=True) # Field name made lowercase.
|
||||
status_date = models.DateField(db_column='Status_Date') # Field name made lowercase.
|
||||
status_time = models.TimeField(db_column='Status_Time', blank=True, null=True) # Field name made lowercase.
|
||||
count_alive = models.IntegerField(db_column='Count_Alive', blank=True, null=True) # Field name made lowercase.
|
||||
count_dead = models.IntegerField(db_column='Count_Dead', 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_Alive_Dead_Counts'
|
||||
|
||||
|
||||
class TblBiorepImageHistology(models.Model):
|
||||
imageid = models.AutoField(db_column='ImageID', primary_key=True) # Field name made lowercase.
|
||||
record_typeid = models.ForeignKey('TblLuRecordTypes', db_column='Record_TypeID') # Field name made lowercase.
|
||||
|
|
Loading…
Add table
Reference in a new issue