Alive-Dead Count

This commit is contained in:
Matthew Ryan Dillon 2016-02-01 15:22:04 -07:00
parent 75cb9a9eea
commit 7c1b12f833
5 changed files with 72 additions and 18 deletions

View file

@ -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)

View 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')),
],
),
]

View file

@ -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)