Experiment
This commit is contained in:
parent
80e96ec81b
commit
55e08501d5
8 changed files with 136 additions and 15 deletions
0
ccdb/experiments/__init__.py
Normal file
0
ccdb/experiments/__init__.py
Normal file
32
ccdb/experiments/admin.py
Normal file
32
ccdb/experiments/admin.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Flaw, Experiment, ProtocolAttachment
|
||||
|
||||
|
||||
class FlawAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'description', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'description')
|
||||
|
||||
|
||||
class ExperimentAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'code', 'description', 'flaw', 'sort_order')
|
||||
list_display_links = ('name',)
|
||||
search_fields = ('name', 'code', 'description', 'flaw', 'sort_order')
|
||||
list_per_page = 25
|
||||
fields = ('name', 'code', 'description', 'flaw', 'sort_order')
|
||||
|
||||
|
||||
class ProtocolAttachmentAdmin(admin.ModelAdmin):
|
||||
list_display = ('experiment', 'protocol')
|
||||
list_display_links = ('protocol',)
|
||||
search_fields = ('protocol',)
|
||||
list_per_page = 25
|
||||
fields = ('experiment', 'protocol')
|
||||
|
||||
|
||||
admin.site.register(Flaw, FlawAdmin)
|
||||
admin.site.register(Experiment, ExperimentAdmin)
|
||||
admin.site.register(ProtocolAttachment, ProtocolAttachmentAdmin)
|
57
ccdb/experiments/migrations/0001_initial.py
Normal file
57
ccdb/experiments/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import autoslug.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Experiment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)),
|
||||
('name', models.CharField(max_length=150)),
|
||||
('code', models.CharField(max_length=10, blank=True)),
|
||||
('description', models.CharField(max_length=255, blank=True)),
|
||||
('sort_order', models.IntegerField(null=True, blank=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['sort_order'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Flaw',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('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'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ProtocolAttachment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, serialize=False, verbose_name='ID', primary_key=True)),
|
||||
('protocol', models.FileField(upload_to='experiments/protocols/%Y/%m/%d')),
|
||||
('experiment', models.ForeignKey(to='experiments.Experiment')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='experiment',
|
||||
name='flaw',
|
||||
field=models.ForeignKey(to='experiments.Flaw', null=True, blank=True),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='experiment',
|
||||
unique_together=set([('name', 'code')]),
|
||||
),
|
||||
]
|
0
ccdb/experiments/migrations/__init__.py
Normal file
0
ccdb/experiments/migrations/__init__.py
Normal file
39
ccdb/experiments/models.py
Normal file
39
ccdb/experiments/models.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from django.db import models
|
||||
|
||||
from autoslug import AutoSlugField
|
||||
|
||||
|
||||
class Flaw(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
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:
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
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)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'code')
|
||||
ordering = ['sort_order']
|
||||
|
||||
|
||||
class ProtocolAttachment(models.Model):
|
||||
experiment = models.ForeignKey(Experiment)
|
||||
protocol = models.FileField(upload_to='experiments/protocols/%Y/%m/%d')
|
||||
|
||||
def __str__(self):
|
||||
return self.protocol
|
|
@ -16,6 +16,7 @@ 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
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -216,3 +217,9 @@ def _import_admin_data():
|
|||
cs.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
# Experiment
|
||||
for r in c.execute('SELECT * FROM tbl_lu_experiments;'):
|
||||
e = Experiment(id=r[0], name=r[1], code=r[2],
|
||||
description=r[3], sort_order=r[6])
|
||||
e.save()
|
||||
|
|
|
@ -45,6 +45,7 @@ LOCAL_APPS = (
|
|||
'ccdb.species',
|
||||
'ccdb.collections_ccdb',
|
||||
'ccdb.processing',
|
||||
'ccdb.experiments',
|
||||
)
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
|
|
|
@ -263,21 +263,6 @@ class TblLuCommentTypes(models.Model):
|
|||
unique_together = (('Comment_Type', 'Comment_Type_Code'),)
|
||||
|
||||
|
||||
class TblLuExperiments(models.Model):
|
||||
experimentid = models.AutoField(db_column='ExperimentID', primary_key=True) # Field name made lowercase.
|
||||
experiment_name = models.CharField(db_column='Experiment_Name', max_length=150) # Field name made lowercase.
|
||||
experiment_code = models.CharField(db_column='Experiment_Code', max_length=10, blank=True, null=True) # Field name made lowercase.
|
||||
experiment_short_description = models.CharField(db_column='Experiment_Short_Description', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
link_to_protocol = models.CharField(db_column='Link_To_Protocol', max_length=255, blank=True, null=True) # Field name made lowercase.
|
||||
flawid = models.ForeignKey('TblLuRecordFlaws', db_column='FlawID', 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_Experiments'
|
||||
unique_together = (('Experiment_Name', 'Experiment_Code'),)
|
||||
|
||||
|
||||
class TblLuPeople(models.Model):
|
||||
peopleid = models.AutoField(db_column='PeopleID', primary_key=True) # Field name made lowercase.
|
||||
affiliationid = models.ForeignKey(TblLuAffiliations, db_column='AffiliationID', blank=True, null=True) # Field name made lowercase.
|
||||
|
|
Loading…
Add table
Reference in a new issue