def itree_regions(self): from treemap.models import ITreeRegion # prevent circular import if self.itree_region_default: codes = [self.itree_region_default] else: codes = ITreeRegion.objects.filter(geometry__intersects=self.bounds).values_list("code", flat=True) return [(code, ITREE_REGIONS.get(code, {}).get("name")) for code in codes]
def itree_regions(self): from treemap.models import ITreeRegion # prevent circular import if self.itree_region_default: codes = [self.itree_region_default] else: codes = (ITreeRegion.objects.filter( geometry__intersects=self.bounds).values_list('code', flat=True)) return [(code, ITREE_REGIONS.get(code, {}).get('name')) for code in codes]
def get_default_for_region(cls, region_code): """ Returns a new BenefitCurrencyConversion for the given i-Tree region """ config = ITREE_REGIONS.get(region_code, {}).get("currency_conversion") if config: benefits_conversion = cls() benefits_conversion.currency_symbol = "$" for field, conversion in config.iteritems(): setattr(benefits_conversion, field, conversion) return benefits_conversion else: return None
def get_default_for_region(cls, region_code): """ Returns a new BenefitCurrencyConversion for the given i-Tree region """ config = ITREE_REGIONS.get(region_code, {})\ .get('currency_conversion') if config: benefits_conversion = cls() benefits_conversion.currency_symbol = '$' for field, conversion in config.iteritems(): setattr(benefits_conversion, field, conversion) return benefits_conversion else: return None
def __unicode__(self): "printed representation, used in templates" return "%s (%s)" % (self.code, ITREE_REGIONS.get(self.code, {}).get('name'))