Finish up collections admin
This commit is contained in:
parent
60601beacb
commit
2c8681217b
7 changed files with 361 additions and 68 deletions
|
@ -14,6 +14,8 @@ from ccdb.locations.models import Region, Site, MunicipalLocation, \
|
|||
StudyLocation, StorageLocation
|
||||
from ccdb.species.models import Species
|
||||
from ccdb.processing.models import ProcessType, Reagent, Flaw, Processing
|
||||
from ccdb.collections_ccdb.models import CollectionType, CollectionMethod, \
|
||||
Flaw, ADFGPermit, Collection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -168,6 +170,39 @@ def _import_admin_data():
|
|||
|
||||
# Reagent
|
||||
for r in c.execute('SELECT * FROM tbl_lu_reagents;'):
|
||||
r = Reagent(id=r[0], name=r[1], code=r[2], reagent_class=r[3],
|
||||
rg = Reagent(id=r[0], name=r[1], code=r[2], reagent_class=r[3],
|
||||
sort_order=r[4])
|
||||
r.save()
|
||||
rg.save()
|
||||
|
||||
# Collection Type
|
||||
for r in c.execute('SELECT * FROM tbl_lu_collection_types;'):
|
||||
ct = CollectionType(id=r[0], name=r[1], code=r[2], sort_order=r[3])
|
||||
ct.save()
|
||||
|
||||
# Collection Method
|
||||
for r in c.execute('SELECT * FROM tbl_lu_collection_methods;'):
|
||||
cm = CollectionMethod(id=r[0], name=r[1], code=r[2],
|
||||
collection_method_class=r[3], sort_order=r[4])
|
||||
cm.save()
|
||||
|
||||
# Collection
|
||||
for r in c.execute('''
|
||||
SELECT *,
|
||||
collection_start_date AS "collection_start_date [dtdt]",
|
||||
collection_start_time AS "collection_start_time [dtdt]",
|
||||
collection_end_date AS "collection_end_date [dtdt]",
|
||||
collection_end_time AS "collection_end_time [dtdt]"
|
||||
FROM tbl_collections;
|
||||
'''):
|
||||
if r[14] is not '':
|
||||
permit, _ = ADFGPermit.objects.get_or_create(name=r[14])
|
||||
else:
|
||||
permit = None
|
||||
col = Collection(project_id=r[0], id=r[1], study_location_id=r[2],
|
||||
collection_type_id=r[3], collection_method_id=r[4],
|
||||
number_of_traps=r[5], collection_start_date=r[17],
|
||||
collection_start_time=r[18], collection_end_date=r[19],
|
||||
collection_end_time=r[20], storage_location_id=r[10],
|
||||
specimen_state=r[11], process_type_id=r[12], reagent_id=r[13],
|
||||
adfg_permit=permit)
|
||||
col.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue