Species
This commit is contained in:
parent
e397e96dab
commit
3be40fe7da
8 changed files with 76 additions and 14 deletions
0
ccdb/species/__init__.py
Normal file
0
ccdb/species/__init__.py
Normal file
14
ccdb/species/admin.py
Normal file
14
ccdb/species/admin.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import Species
|
||||||
|
|
||||||
|
|
||||||
|
class SpeciesAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
|
||||||
|
list_display_links = ('common_name',)
|
||||||
|
search_fields = ('common_name', 'genus', 'species', 'parasite')
|
||||||
|
list_per_page = 25
|
||||||
|
fields = ('common_name', 'genus', 'species', 'parasite', 'sort_order')
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Species, SpeciesAdmin)
|
34
ccdb/species/migrations/0001_initial.py
Normal file
34
ccdb/species/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- 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='Species',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)),
|
||||||
|
('common_name', models.CharField(max_length=100)),
|
||||||
|
('genus', models.CharField(max_length=50, blank=True)),
|
||||||
|
('species', models.CharField(max_length=50, blank=True)),
|
||||||
|
('parasite', models.BooleanField(default=False)),
|
||||||
|
('sort_order', models.IntegerField(blank=True, null=True)),
|
||||||
|
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='common_name')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['sort_order'],
|
||||||
|
'verbose_name_plural': 'species',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name='species',
|
||||||
|
unique_together=set([('common_name', 'species')]),
|
||||||
|
),
|
||||||
|
]
|
0
ccdb/species/migrations/__init__.py
Normal file
0
ccdb/species/migrations/__init__.py
Normal file
20
ccdb/species/models.py
Normal file
20
ccdb/species/models.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from autoslug import AutoSlugField
|
||||||
|
|
||||||
|
|
||||||
|
class Species(models.Model):
|
||||||
|
common_name = models.CharField(max_length=100)
|
||||||
|
genus = models.CharField(max_length=50, blank=True)
|
||||||
|
species = models.CharField(max_length=50, blank=True)
|
||||||
|
parasite = models.BooleanField(default=False)
|
||||||
|
sort_order = models.IntegerField(blank=True, null=True)
|
||||||
|
slug = AutoSlugField(populate_from='common_name')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.common_name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ('common_name', 'species')
|
||||||
|
ordering = ['sort_order']
|
||||||
|
verbose_name_plural = 'species'
|
|
@ -12,6 +12,7 @@ from ccdb.misc.models import MeasurementUnit, MeasurementType, Container, \
|
||||||
Material, Color
|
Material, Color
|
||||||
from ccdb.locations.models import Region, Site, MunicipalLocation, \
|
from ccdb.locations.models import Region, Site, MunicipalLocation, \
|
||||||
StudyLocation, StorageLocation
|
StudyLocation, StorageLocation
|
||||||
|
from ccdb.species.models import Species
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -151,3 +152,9 @@ def _import_data():
|
||||||
room=r[3], freezer=r[4], temp_c=r[5], code=code,
|
room=r[3], freezer=r[4], temp_c=r[5], code=code,
|
||||||
description=r[6], sort_order=r[7])
|
description=r[6], sort_order=r[7])
|
||||||
sl.save()
|
sl.save()
|
||||||
|
|
||||||
|
# Species
|
||||||
|
for r in c.execute('SELECT * FROM tbl_lu_species;'):
|
||||||
|
s = Species(id=r[0], common_name=r[1], genus=r[2], species=r[3],
|
||||||
|
parasite=r[4], sort_order=r[5])
|
||||||
|
s.save()
|
||||||
|
|
|
@ -42,6 +42,7 @@ LOCAL_APPS = (
|
||||||
'ccdb.projects',
|
'ccdb.projects',
|
||||||
'ccdb.misc',
|
'ccdb.misc',
|
||||||
'ccdb.locations',
|
'ccdb.locations',
|
||||||
|
'ccdb.species',
|
||||||
)
|
)
|
||||||
|
|
||||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||||
|
|
|
@ -461,20 +461,6 @@ class TblLuSampleTypes(models.Model):
|
||||||
unique_together = (('Sample_Type', 'Sample_Type_Code'),)
|
unique_together = (('Sample_Type', 'Sample_Type_Code'),)
|
||||||
|
|
||||||
|
|
||||||
class TblLuSpecies(models.Model):
|
|
||||||
speciesid = models.AutoField(db_column='SpeciesID', primary_key=True) # Field name made lowercase.
|
|
||||||
common_name = models.CharField(db_column='Common_Name', max_length=100) # Field name made lowercase.
|
|
||||||
genus = models.CharField(db_column='Genus', max_length=50, blank=True, null=True) # Field name made lowercase.
|
|
||||||
species = models.CharField(db_column='Species', max_length=50, blank=True, null=True) # Field name made lowercase.
|
|
||||||
parasite = models.BooleanField(db_column='Parasite') # 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_Species'
|
|
||||||
unique_together = (('Common_Name', 'Species'),)
|
|
||||||
|
|
||||||
|
|
||||||
class TblLuTreatmentTypes(models.Model):
|
class TblLuTreatmentTypes(models.Model):
|
||||||
treatment_typeid = models.AutoField(db_column='Treatment_TypeID', primary_key=True) # Field name made lowercase.
|
treatment_typeid = models.AutoField(db_column='Treatment_TypeID', primary_key=True) # Field name made lowercase.
|
||||||
experimentid = models.ForeignKey(TblLuExperiments, db_column='ExperimentID', blank=True, null=True) # Field name made lowercase.
|
experimentid = models.ForeignKey(TblLuExperiments, db_column='ExperimentID', blank=True, null=True) # Field name made lowercase.
|
||||||
|
|
Loading…
Add table
Reference in a new issue