Skip to content

Commit

Permalink
Merge pull request #31 from ahinz/topic/unit
Browse files Browse the repository at this point in the history
Inject i18n support for eco benefit values
  • Loading branch information
ahinz committed Nov 8, 2012
2 parents cfc2c43 + 1f0baa6 commit 23f5f73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 6 additions & 4 deletions static/treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ tm = {

searchParams: {},

benefitUnitTransformer: function(k,v) { return v; },

//initializes the map where a user places a new tree
get_icon: function(type, size) {
var size = new OpenLayers.Size(size, size);
Expand Down Expand Up @@ -87,8 +89,8 @@ tm = {
{
$("#no_results").show();
}
},
},

display_summaries : function(summaries){
$(".tree_count").html(tm.addCommas(parseInt(summaries.total_trees)));
$(".plot_count").html(tm.addCommas(parseInt(summaries.total_plots)));
Expand All @@ -100,11 +102,11 @@ tm = {
$(".moretrees").html("");
$(".notrees").html("");
}

$.each(summaries, function(k,v){
var span = $('#' + k);
if (span.length > 0){
span.html(tm.addCommas(parseInt(v)));
span.html(tm.addCommas(
tm.benefitUnitTransformer(k,parseInt(v))));
}
});

Expand Down
14 changes: 14 additions & 0 deletions treemap/templatetags/tree_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
from django.db.models import get_model

register = Library()

@register.filter
def gal2litres(value):
if value:
return value * 3.78541
else:
return value

@register.filter
def lbs2kgs(value):
if value:
return value * 0.453592
else:
return value

@register.filter
def unit_or_missing(value, unit=None):
Expand Down

0 comments on commit 23f5f73

Please sign in to comment.