Skip to content

Commit

Permalink
Drop tenure_type_label for imports and exports
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed May 16, 2017
1 parent aaa98d1 commit 393f556
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 27 deletions.
3 changes: 1 addition & 2 deletions cadasta/organization/download/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def write_relationships(self, filename):
content_type = ContentType.objects.get(app_label='party',
model='tenurerelationship')
self.write_items(filename, relationships, content_type,
('id', 'party_id', 'spatial_unit_id', 'tenure_type',
'tenure_type_label'))
('id', 'party_id', 'spatial_unit_id', 'tenure_type'))

def write_parties(self, filename):
parties = self.project.parties.all()
Expand Down
3 changes: 1 addition & 2 deletions cadasta/organization/download/xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def write_relationships(self):
content_type = ContentType.objects.get(app_label='party',
model='tenurerelationship')
self.write_items(worksheet, relationships, content_type,
['party_id', 'spatial_unit_id', 'tenure_type',
'tenure_type_label'])
['party_id', 'spatial_unit_id', 'tenure_type'])

def make_download(self, f_name):
path = os.path.join(settings.MEDIA_ROOT, 'temp/{}.xlsx'.format(f_name))
Expand Down
5 changes: 1 addition & 4 deletions cadasta/organization/importers/xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ def get_csv_from_dataframe(df, entity_types):
right_on='party::id', how='outer'
)
# drop unused columns
drop_cols = [
'spatialunit::id', 'party::id',
'tenurerelationship::tenure_type_label'
]
drop_cols = ['spatialunit::id', 'party::id']
merged.drop(drop_cols, inplace=True, axis=1)

return merged.to_csv(index=False, index_label=False)
Expand Down
Binary file modified cadasta/organization/tests/files/test_conditionals.xlsx
Binary file not shown.
Binary file modified cadasta/organization/tests/files/test_download.xlsx
Binary file not shown.
Binary file modified cadasta/organization/tests/files/test_one_to_many.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions cadasta/organization/tests/test_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@ def test_write_relationships(self):
for i, row in enumerate(csvreader):
if i == 0:
assert row == ['id', 'party_id', 'spatial_unit_id',
'tenure_type', 'tenure_type_label']
'tenure_type']
else:
assert row == [
self.tenurerelationship.id, self.parties[0].id,
self.spatialunit_1.id, 'CR', 'Eigentum']
self.spatialunit_1.id, 'CR']

# remove this so other tests pass
os.remove(filename)
Expand Down
2 changes: 1 addition & 1 deletion cadasta/search/export/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, project):
model='tenurerelationship'),
'schema_attrs': schema_attrs['party.tenurerelationship'],
'model_attrs': ['id', 'party_id', 'spatial_unit_id',
'tenure_type_id', 'tenure_type_label'],
'tenure_type_id'],
},
}

Expand Down
24 changes: 8 additions & 16 deletions cadasta/search/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ def test_init(self):
assert list(attrs.keys()) == ['notes']
assert metadatum['model_attrs'] == ['id', 'party_id',
'spatial_unit_id',
'tenure_type_id',
'tenure_type_label']
'tenure_type_id']
assert list(metadatum['attr_columns'].keys()) == [
'id', 'party_id', 'spatial_unit_id', 'tenure_type_id',
'tenure_type_label', 'notes']
'id', 'party_id', 'spatial_unit_id', 'tenure_type_id', 'notes']

def test_get_attr_values(self):
location_data = {
Expand Down Expand Up @@ -361,14 +359,12 @@ def test_make_download_standalone(self):
assert rows[0][1] == 'party_id'
assert rows[0][2] == 'spatial_unit_id'
assert rows[0][3] == 'tenure_type_id'
assert rows[0][4] == 'tenure_type_label'
assert rows[0][5] == 'notes'
assert rows[0][4] == 'notes'
assert rows[1][0] == 'ID2'
assert rows[1][1] == 'ID1'
assert rows[1][2] == 'ID0'
assert rows[1][3] == 'CU'
assert rows[1][4] == "Customary Rights"
assert rows[1][5] == "The best relationship!"
assert rows[1][4] == "The best relationship!"

def test_make_download_not_standalone(self):
ensure_dirs()
Expand Down Expand Up @@ -516,14 +512,12 @@ def test_make_download(self):
assert ws['B1'].value == 'party_id'
assert ws['C1'].value == 'spatial_unit_id'
assert ws['D1'].value == 'tenure_type_id'
assert ws['E1'].value == 'tenure_type_label'
assert ws['F1'].value == 'notes'
assert ws['E1'].value == 'notes'
assert ws['A2'].value == 'ID2'
assert ws['B2'].value == 'ID1'
assert ws['C2'].value == 'ID0'
assert ws['D2'].value == 'CU'
assert ws['E2'].value == "Customary Rights"
assert ws['F2'].value == "The best relationship!"
assert ws['E2'].value == "The best relationship!"

def test_make_download_empty(self):
ensure_dirs()
Expand Down Expand Up @@ -794,14 +788,12 @@ def test_make_download(self):
assert ws['B1'].value == 'party_id'
assert ws['C1'].value == 'spatial_unit_id'
assert ws['D1'].value == 'tenure_type_id'
assert ws['E1'].value == 'tenure_type_label'
assert ws['F1'].value == 'notes'
assert ws['E1'].value == 'notes'
assert ws['A2'].value == 'ID2'
assert ws['B2'].value == 'ID1'
assert ws['C2'].value == 'ID0'
assert ws['D2'].value == 'CU'
assert ws['E2'].value == "Customary Rights"
assert ws['F2'].value == "The best relationship!"
assert ws['E2'].value == "The best relationship!"

def test_make_download_empty(self):
ensure_dirs()
Expand Down

0 comments on commit 393f556

Please sign in to comment.