Skip to content

Commit

Permalink
Merge pull request #2 from sleitner/table-download
Browse files Browse the repository at this point in the history
Translate Summary Table CSV column names to English
  • Loading branch information
contolini committed Mar 15, 2016
2 parents 35a72b7 + 981c888 commit 3f7e580
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions mapusaurus/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ def test_api_tables_csv(self):
'peer_hma_pct', 'peer_lma_pct', 'peer_mma_pct', 'peer_lma', 'peer_mma',
'peer_hma', 'peer_lar_total', 'odds_lma', 'odds_mma', 'odds_hma']
keys = input_keys + lender_keys
header_dict = { "msa_or_county_id":"MSA or County ID",
"peer_lar_total":"Total LAR of Peers","name":"County Name",
"hma_pct":"Pct in HMA","lma_pct":"Pct in LMA","mma_pct":"Pct in MMA",
"lma":"LAR Count in LMA","mma":"LAR Count in MMA","hma":"LAR Count in HMA",
"lar_total":"Total LAR in MSA","peer_hma_pct":"Odds Ratio in HMA",
"peer_mma_pct":"Odds Ratio in MMA","peer_lma_pct":"Odds Ratio in LMA",
"peer_lma":"Total Peer LAR in LMA","peer_mma":"Total Peer LAR in MMA",
"peer_hma":"Total Peer LAR in HMA",
"odds_lma":"odds LMA","odds_mma":"Odds MMA","odds_hma":"Odds HMA"}
for key in keys:
self.assertTrue(key in result_dict.keys())
self.assertTrue(len(result_dict['msa_or_county_id']) > 0)
self.assertTrue(header_dict[key] in result_dict.keys())
self.assertTrue(len(result_dict[header_dict['msa_or_county_id']]) > 0)
11 changes: 10 additions & 1 deletion mapusaurus/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,20 @@ def tables_csv(request):
'peer_hma_pct', 'peer_lma_pct', 'peer_mma_pct', 'peer_lma', 'peer_mma',
'peer_hma', 'peer_lar_total', 'odds_lma', 'odds_mma', 'odds_hma']
keys = input_keys + lender_keys
header_dict = {"msa_or_county_id":"MSA or County ID",
"peer_lar_total":"Total LAR of Peers","name":"County Name",
"hma_pct":"Pct in HMA","lma_pct":"Pct in LMA","mma_pct":"Pct in MMA",
"lma":"LAR Count in LMA","mma":"LAR Count in MMA","hma":"LAR Count in HMA",
"lar_total":"Total LAR in MSA","peer_hma_pct":"Odds Ratio in HMA",
"peer_mma_pct":"Odds Ratio in MMA","peer_lma_pct":"Odds Ratio in LMA",
"peer_lma":"Total Peer LAR in LMA" ,"peer_mma":"Total Peer LAR in MMA",
"peer_hma":"Total Peer LAR in HMA",
"odds_lma":"odds LMA", "odds_mma":"Odds MMA", "odds_hma":"Odds HMA"}
msa['msa_or_county_id'] = institution_id
# MSA has no county name so insert the word "MSA"
msa['name'] = 'MSA'
writer = csv.writer(response, csv.excel)
writer.writerow(keys)
writer.writerow([header_dict[k] for k in keys])
writer.writerow([msa[k] for k in keys])
for id,county in counties.iteritems():
county = counties[id]
Expand Down
2 changes: 1 addition & 1 deletion mapusaurus/censusdata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def race_summary_csv(request):
smart_str(u"White Only Percentage"),
smart_str(u"Non Hispanic Black Only Percentage"),
smart_str(u"Non Hispanic Asian Only Percentage"),
smart_str(u"HMDA LAR Count"),
smart_str(u"Originated Loans"),
smart_str(u"Total Households"),
])
for obj in queryset:
Expand Down
2 changes: 1 addition & 1 deletion mapusaurus/mapping/templates/partial/map_actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h6 class="item-sub">Download the {{ year }} loan application records (LAR) for
<div class="map-divider download-census">
<div class="header-group">
<h3 class="tab-main">Census data</h3>
<h6 class="item-sub">Download the 2010 SF-1 Census demographic data for {{ metro.name }}. This download also includes LAR counts by tract, filtered as explained below.</h6>
<h6 class="item-sub">Download the 2010 SF-1 Census demographic data for {{ metro.name }}. This download also includes originated loan counts by tract.</h6>
<a target="_blank" id="downloadCensus" href="/census/race_summary_csv/" class="btn btn__secondary">
<span class="btn_icon__left cf-icon cf-icon-download"></span>
Download CSV
Expand Down

0 comments on commit 3f7e580

Please sign in to comment.