Set backref labels

Fixes #6
This commit is contained in:
Matthew Ryan Dillon 2016-06-15 10:43:02 -07:00
parent dbfe88610a
commit 70046b5104
14 changed files with 357 additions and 40 deletions

View file

@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('collections_ccdb', '0005_DATA_initial'),
]
operations = [
migrations.AlterField(
model_name='collection',
name='adfg_permit',
field=models.ForeignKey(null=True, related_name='collections', to='collections_ccdb.ADFGPermit', blank=True),
),
migrations.AlterField(
model_name='collection',
name='collection_method',
field=models.ForeignKey(to='collections_ccdb.CollectionMethod', related_name='collections'),
),
migrations.AlterField(
model_name='collection',
name='collection_type',
field=models.ForeignKey(to='collections_ccdb.CollectionType', related_name='collections'),
),
migrations.AlterField(
model_name='collection',
name='flaw',
field=models.ForeignKey(null=True, related_name='collections', to='collections_ccdb.Flaw', blank=True),
),
migrations.AlterField(
model_name='collection',
name='process_type',
field=models.ForeignKey(null=True, related_name='collections', to='processing.ProcessType', blank=True),
),
migrations.AlterField(
model_name='collection',
name='project',
field=models.ForeignKey(to='projects.Project', related_name='collections'),
),
migrations.AlterField(
model_name='collection',
name='reagent',
field=models.ForeignKey(null=True, related_name='collections', to='processing.Reagent', blank=True),
),
migrations.AlterField(
model_name='collection',
name='storage_location',
field=models.ForeignKey(null=True, related_name='collections', to='locations.StorageLocation', blank=True),
),
migrations.AlterField(
model_name='collection',
name='study_location',
field=models.ForeignKey(to='locations.StudyLocation', related_name='collections'),
),
migrations.AlterField(
model_name='collectiontrap',
name='collection',
field=models.ForeignKey(to='collections_ccdb.Collection', related_name='traps'),
),
migrations.AlterField(
model_name='datasheetattachment',
name='collection',
field=models.ForeignKey(to='collections_ccdb.Collection', related_name='datasheets'),
),
]

View file

@ -59,21 +59,26 @@ class ADFGPermit(models.Model):
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)
project = models.ForeignKey('projects.Project', related_name='collections')
study_location = models.ForeignKey('locations.StudyLocation',
related_name='collections')
collection_type = models.ForeignKey(CollectionType, related_name='collections')
collection_method = models.ForeignKey(CollectionMethod, related_name='collections')
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)
storage_location = models.ForeignKey('locations.StorageLocation', blank=True,
null=True, related_name='collections')
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)
process_type = models.ForeignKey('processing.ProcessType', blank=True,
null=True, related_name='collections')
reagent = models.ForeignKey('processing.Reagent', blank=True, null=True,
related_name='collections')
adfg_permit = models.ForeignKey(ADFGPermit, blank=True, null=True,
related_name='collections')
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='collections')
display_name = models.CharField(max_length=255, editable=False)
def save(self, *args, **kwargs):
@ -92,13 +97,13 @@ class Collection(models.Model):
class DatasheetAttachment(models.Model):
collection = models.ForeignKey(Collection)
collection = models.ForeignKey(Collection, related_name='datasheets')
datasheet = models.FileField("Datasheet",
upload_to='collections/datasheets/%Y/%m/%d')
class CollectionTrap(models.Model):
collection = models.ForeignKey(Collection)
collection = models.ForeignKey(Collection, related_name='traps')
number_of_traps = models.IntegerField()
date_opened = models.DateField()
time_opened = models.TimeField()

View file

@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('experiments', '0010_DATA_collections_experiments'),
]
operations = [
migrations.AlterField(
model_name='alivedeadcount',
name='flaw',
field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='alive_dead_counts', blank=True),
),
migrations.AlterField(
model_name='alivedeadcount',
name='treatment_replicate',
field=models.ForeignKey(to='experiments.TreatmentReplicate', related_name='alive_dead_counts'),
),
migrations.AlterField(
model_name='experiment',
name='flaw',
field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='experiments', blank=True),
),
migrations.AlterField(
model_name='protocolattachment',
name='experiment',
field=models.ForeignKey(to='experiments.Experiment', related_name='protocols'),
),
migrations.AlterField(
model_name='treatment',
name='container',
field=models.ForeignKey(null=True, to='misc.Container', related_name='treatments', blank=True),
),
migrations.AlterField(
model_name='treatment',
name='flaw',
field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='treatments', blank=True),
),
migrations.AlterField(
model_name='treatment',
name='species',
field=models.ForeignKey(to='species.Species', related_name='treatments'),
),
migrations.AlterField(
model_name='treatment',
name='study_location',
field=models.ForeignKey(to='locations.StudyLocation', related_name='treatments'),
),
migrations.AlterField(
model_name='treatment',
name='treatment_type',
field=models.ForeignKey(to='experiments.TreatmentType', related_name='treatments'),
),
migrations.AlterField(
model_name='treatmentreplicate',
name='flaw',
field=models.ForeignKey(null=True, to='experiments.Flaw', related_name='treatment_replicates', blank=True),
),
migrations.AlterField(
model_name='treatmentreplicate',
name='treatment',
field=models.ForeignKey(to='experiments.Treatment', related_name='treatment_replicates'),
),
migrations.AlterField(
model_name='treatmenttype',
name='experiment',
field=models.ForeignKey(null=True, to='experiments.Experiment', related_name='treatment_types', blank=True),
),
]

View file

@ -20,7 +20,7 @@ class Experiment(models.Model):
name = models.CharField(max_length=150)
code = models.CharField(max_length=10, blank=True)
description = models.CharField(max_length=255, blank=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='experiments')
sort_order = models.IntegerField(blank=True, null=True)
slug = AutoSlugField(populate_from='name')
collections = models.ManyToManyField('collections_ccdb.Collection')
@ -34,7 +34,7 @@ class Experiment(models.Model):
class ProtocolAttachment(models.Model):
experiment = models.ForeignKey(Experiment)
experiment = models.ForeignKey(Experiment, related_name='protocols')
protocol = models.FileField(upload_to='experiments/protocols/%Y/%m/%d')
def __str__(self):
@ -42,7 +42,8 @@ class ProtocolAttachment(models.Model):
class TreatmentType(models.Model):
experiment = models.ForeignKey(Experiment, blank=True, null=True)
experiment = models.ForeignKey(Experiment, blank=True, null=True,
related_name='treatment_types')
name = models.CharField(max_length=200)
code = models.CharField(max_length=25, blank=True)
treatment_type = models.CharField(max_length=50, blank=True)
@ -61,12 +62,14 @@ class TreatmentType(models.Model):
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')
treatment_type = models.ForeignKey(TreatmentType, related_name='treatments')
container = models.ForeignKey('misc.Container', blank=True, null=True,
related_name='treatments')
study_location = models.ForeignKey('locations.StudyLocation',
related_name='treatments')
species = models.ForeignKey('species.Species', related_name='treatments')
sex = models.CharField(max_length=25)
flaw = models.ForeignKey(Flaw, blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='treatments')
display_name = models.CharField(max_length=255, editable=False)
def save(self, *args, **kwargs):
@ -80,13 +83,13 @@ class Treatment(models.Model):
class TreatmentReplicate(models.Model):
treatment = models.ForeignKey(Treatment)
treatment = models.ForeignKey(Treatment, related_name='treatment_replicates')
name = models.CharField(max_length=50)
setup_date = models.DateField(blank=True, null=True)
setup_time = models.TimeField(blank=True, null=True)
setup_sample_size = models.IntegerField(blank=True, null=True)
mass_g = models.FloatField(blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='treatment_replicates')
display_name = models.CharField(max_length=255, editable=False)
def save(self, *args, **kwargs):
@ -103,12 +106,14 @@ class TreatmentReplicate(models.Model):
class AliveDeadCount(models.Model):
treatment_replicate = models.ForeignKey(TreatmentReplicate)
treatment_replicate = models.ForeignKey(TreatmentReplicate,
related_name='alive_dead_counts')
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)
flaw = models.ForeignKey(Flaw, blank=True, null=True,
related_name='alive_dead_counts')
def __str__(self):
return "{}".format(self.status_date)

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('locations', '0004_DATA_initial'),
]
operations = [
migrations.AlterField(
model_name='site',
name='region',
field=models.ForeignKey(blank=True, related_name='sites', null=True, to='locations.Region'),
),
migrations.AlterField(
model_name='studylocation',
name='municipal_location',
field=models.ForeignKey(blank=True, related_name='study_locations', null=True, to='locations.MunicipalLocation'),
),
migrations.AlterField(
model_name='studylocation',
name='site',
field=models.ForeignKey(related_name='study_locations', to='locations.Site'),
),
]

View file

@ -18,7 +18,7 @@ class Region(models.Model):
class Site(models.Model):
region = models.ForeignKey(Region, blank=True, null=True)
region = models.ForeignKey(Region, blank=True, null=True, related_name='sites')
name = models.CharField(max_length=100)
code = models.CharField(max_length=10, blank=True)
description = models.CharField(max_length=255, blank=True)
@ -48,13 +48,13 @@ class MunicipalLocation(models.Model):
class StudyLocation(models.Model):
site = models.ForeignKey(Site)
site = models.ForeignKey(Site, related_name='study_locations')
name = models.CharField(max_length=100)
code = models.CharField(max_length=10)
study_location_type = models.CharField(max_length=50, blank=True)
treatment_type = models.CharField(max_length=100, blank=True)
municipal_location = models.ForeignKey(MunicipalLocation,
blank=True, null=True)
blank=True, null=True, related_name='study_locations')
collecting_location = models.BooleanField(default=False)
description = models.CharField(max_length=255, blank=True)
sort_order = models.IntegerField(blank=True, null=True)

View file

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('misc', '0002_DATA_initial'),
]
operations = [
migrations.AlterField(
model_name='container',
name='color',
field=models.ForeignKey(related_name='containers', blank=True, to='misc.Color', null=True),
),
migrations.AlterField(
model_name='container',
name='material',
field=models.ForeignKey(related_name='containers', blank=True, to='misc.Material', null=True),
),
migrations.AlterField(
model_name='container',
name='measurement_unit',
field=models.ForeignKey(related_name='containers', blank=True, to='misc.MeasurementUnit', null=True),
),
migrations.AlterField(
model_name='measurementtype',
name='default_measurement_unit',
field=models.ForeignKey(related_name='measurement_types', blank=True, to='misc.MeasurementUnit', null=True),
),
]

View file

@ -24,7 +24,9 @@ class MeasurementType(models.Model):
code = models.CharField(max_length=10, blank=True)
measurement_type_class = models.CharField(max_length=50, blank=True)
description = models.CharField(max_length=255, blank=True)
default_measurement_unit = models.ForeignKey('MeasurementUnit', blank=True, null=True)
default_measurement_unit = models.ForeignKey('MeasurementUnit', blank=True,
null=True,
related_name='measurement_types')
sort_order = models.IntegerField(blank=True, null=True)
slug = AutoSlugField(populate_from='name')
@ -70,10 +72,13 @@ class Container(models.Model):
name = models.CharField(max_length=100)
code = models.CharField(max_length=10, blank=True)
application = models.CharField(max_length=50, blank=True)
color = models.ForeignKey(Color, blank=True, null=True)
material = models.ForeignKey(Material, blank=True, null=True)
color = models.ForeignKey(Color, blank=True, null=True,
related_name='containers')
material = models.ForeignKey(Material, blank=True, null=True,
related_name='containers')
volume = models.FloatField(blank=True, null=True)
measurement_unit = models.ForeignKey(MeasurementUnit, blank=True, null=True)
measurement_unit = models.ForeignKey(MeasurementUnit, blank=True, null=True,
related_name='containers')
sort_order = models.IntegerField(blank=True, null=True)
slug = AutoSlugField(populate_from='name')

View file

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('processing', '0002_DATA_initial'),
]
operations = [
migrations.AlterField(
model_name='processing',
name='container',
field=models.ForeignKey(related_name='processings', to='misc.Container'),
),
migrations.AlterField(
model_name='processing',
name='flaw',
field=models.ForeignKey(to='processing.Flaw', blank=True, related_name='processings', null=True),
),
migrations.AlterField(
model_name='processing',
name='measurement_unit',
field=models.ForeignKey(to='misc.MeasurementUnit', blank=True, related_name='processings', null=True),
),
migrations.AlterField(
model_name='processing',
name='process_type',
field=models.ForeignKey(related_name='processings', to='processing.ProcessType'),
),
migrations.AlterField(
model_name='processing',
name='reagent',
field=models.ForeignKey(to='processing.Reagent', blank=True, related_name='processings', null=True),
),
]

View file

@ -47,16 +47,18 @@ class Flaw(models.Model):
class Processing(models.Model):
process_type = models.ForeignKey(ProcessType)
container = models.ForeignKey('misc.Container')
process_type = models.ForeignKey(ProcessType, related_name='processings')
container = models.ForeignKey('misc.Container', related_name='processings')
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 = models.ForeignKey(Reagent, blank=True, null=True,
related_name='processings')
reagent_volume = models.FloatField(blank=True, null=True)
measurement_unit = models.ForeignKey('misc.MeasurementUnit', blank=True, null=True)
measurement_unit = models.ForeignKey('misc.MeasurementUnit', blank=True,
null=True, related_name='processings')
minutes_in_reagent = models.IntegerField(blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True)
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='processings')
def __str__(self):
return "{} {} {}".format(self.process_date, self.process_type, self.container_label)

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projects', '0005_DATA_initial'),
]
operations = [
migrations.AlterField(
model_name='grantreport',
name='grant',
field=models.ForeignKey(to='projects.Grant', related_name='reports'),
),
]

View file

@ -35,7 +35,7 @@ class Grant(models.Model):
class GrantReport(models.Model):
grant = models.ForeignKey(Grant)
grant = models.ForeignKey(Grant, related_name='reports')
title = models.CharField(max_length=200)
report_type = models.CharField(max_length=50, blank=True)
description = models.CharField(max_length=255, blank=True)

View file

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('species', '0005_DATA_species_collection'),
]
operations = [
migrations.AlterField(
model_name='collectionspecies',
name='collection',
field=models.ForeignKey(related_name='collection_species', to='collections_ccdb.Collection'),
),
migrations.AlterField(
model_name='collectionspecies',
name='species',
field=models.ForeignKey(related_name='collection_species', to='species.Species'),
),
migrations.AlterField(
model_name='trapspecies',
name='collection_trap',
field=models.ForeignKey(related_name='trap_species', to='collections_ccdb.CollectionTrap'),
),
migrations.AlterField(
model_name='trapspecies',
name='species',
field=models.ForeignKey(related_name='trap_species', to='species.Species'),
),
]

View file

@ -21,8 +21,9 @@ class Species(models.Model):
class TrapSpecies(models.Model):
collection_trap = models.ForeignKey('collections_ccdb.CollectionTrap')
species = models.ForeignKey(Species)
collection_trap = models.ForeignKey('collections_ccdb.CollectionTrap',
related_name='trap_species')
species = models.ForeignKey(Species, related_name='trap_species')
sex = models.CharField(max_length=25, blank=True)
count = models.IntegerField(blank=True, null=True)
count_estimated = models.BooleanField(default=False)
@ -35,8 +36,9 @@ class TrapSpecies(models.Model):
class CollectionSpecies(models.Model):
collection = models.ForeignKey('collections_ccdb.Collection')
species = models.ForeignKey(Species)
collection = models.ForeignKey('collections_ccdb.Collection',
related_name='collection_species')
species = models.ForeignKey(Species, related_name='collection_species')
sex = models.CharField(max_length=25, blank=True)
count = models.IntegerField(blank=True, null=True)
count_estimated = models.BooleanField(default=False)