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