Skip to content

Commit

Permalink
Merge pull request #72 from carlosp420/dataset
Browse files Browse the repository at this point in the history
only select needed values, not everything
  • Loading branch information
carlosp420 committed Feb 2, 2015
2 parents c0be86e + ef1288b commit ef338ae
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions test_db_dump.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
<row>
<field name="code">CP100-09</field>
<field name="orden"></field>
<field name="superfamily">Papilionoidea</field>
<field name="family">Nymphalidae</field>
<field name="subfamily">Nymphalinae</field>
<field name="tribe">NULL </field>
Expand Down Expand Up @@ -420,6 +421,7 @@
<row>
<field name="code">CP100-10</field>
<field name="orden">NULL</field>
<field name="superfamily">Papilionoidea</field>
<field name="family"></field>
<field name="subfamily"></field>
<field name="tribe">Melitaeini</field>
Expand Down
1 change: 1 addition & 0 deletions voseq/create_dataset/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class CreateDatasetForm(BaseDatasetForm):
choices=[
('CODE', 'Code'),
('ORDER', 'Order'),
('SUPERFAMILY', 'Superfamily'),
('FAMILY', 'Family'),
('SUBFAMILY', 'Subfamily'),
('TRIBE', 'Tribe'),
Expand Down
6 changes: 3 additions & 3 deletions voseq/create_dataset/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUp(self):
'taxonset': None,
'voucher_codes': 'CP100-10\r\nCP100-11',
'geneset': None,
'taxon_names': ['CODE', 'GENUS', 'SPECIES']
'taxon_names': ['CODE', 'SUPERFAMILY', 'GENUS', 'SPECIES']
}

self.c = Client()
Expand All @@ -33,8 +33,8 @@ def test_create_dataset(self):

def test_get_taxon_names_for_taxa(self):
expected = [
{'code': 'CP100-10', 'genus': 'Melitaea', 'species': 'diamina'},
{'code': 'CP100-11', 'genus': 'Melitaea', 'species': 'diamina'},
{'code': 'CP100-10', 'genus': 'Melitaea', 'species': 'diamina', 'superfamily': 'Papilionoidea'},
{'code': 'CP100-11', 'genus': 'Melitaea', 'species': 'diamina', 'superfamily': ''},
]
result = self.dataset_creator.get_taxon_names_for_taxa()

Expand Down
5 changes: 4 additions & 1 deletion voseq/create_dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def get_taxon_names_for_taxa(self):
vouchers_with_taxon_names = []
append = vouchers_with_taxon_names.append

all_vouchers = Vouchers.objects.all().order_by('code').values()
all_vouchers = Vouchers.objects.all().order_by('code').values('code', 'orden', 'superfamily',
'family', 'subfamily', 'tribe',
'subtribe', 'genus', 'species',
'subspecies', 'auctor', 'hostorg',)
for voucher in all_vouchers:
code = voucher['code'].lower()
if code in self.voucher_codes:
Expand Down
6 changes: 5 additions & 1 deletion voseq/public_interface/management/commands/_migrate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

TZINFO = pytz.utc

if settings.TESTING:
if settings.TESTING is True:
TESTING = True
else:
TESTING = False
Expand Down Expand Up @@ -429,6 +429,10 @@ def parse_table_vouchers(self, xml_string):
item = dict()
item['code'] = row.find("./field/[@name='code']").text
item['orden'] = row.find("./field/[@name='orden']").text
try:
item['superfamily'] = row.find("./field/[@name='superfamily']").text
except AttributeError:
item['superfamily'] = ''
item['family'] = row.find("./field/[@name='family']").text
item['subfamily'] = row.find("./field/[@name='subfamily']").text
item['tribe'] = row.find("./field/[@name='tribe']").text
Expand Down
2 changes: 1 addition & 1 deletion voseq/public_interface/tests/test_migrate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_orden_space(self):

def test_superfamily(self):
b = Vouchers.objects.get(code='CP100-10')
self.assertEqual('', b.superfamily)
self.assertEqual('Papilionoidea', b.superfamily)

def test_family(self):
b = Vouchers.objects.get(code='CP100-09')
Expand Down
2 changes: 2 additions & 0 deletions voseq/voseq/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@

# This VoSeq version
VERSION = '2.0.0'

TESTING = False

0 comments on commit ef338ae

Please sign in to comment.