def test_number_formatters(): with override_settings(SHOOP_HOME_CURRENCY="USD"): with translation.override("en-US"): assert percent(Decimal("0.38")) == "38%" assert number(Decimal("38.00000")) == "38" assert number(Decimal("38.05000")) == "38.05" assert home_currency(Decimal("29.99")) == "$29.99" with translation.override("fi-FI"): assert percent(Decimal("0.38")) == "38\xa0%" assert number(Decimal("38.00000")) == "38" assert number(Decimal("38.05000")) == "38,05" assert home_currency(Decimal("29.99")) == "29,99\xa0$"
def label_from_instance(self, obj): label = force_text(obj) if hasattr(obj, "get_effective_name"): label = force_text(obj.get_effective_name(self.basket)) if self.basket and self.show_prices and hasattr(obj, "get_effective_taxless_price"): try: price = obj.get_effective_taxless_price(self.basket) if price: formatted_price = home_currency(price) label = "%s (%s)" % (label, formatted_price) # TODO: Add tax handling. except: LOG.exception("Unable to get or format method price for method %s" % obj) return label
def label_from_instance(self, obj): label = force_text(obj) if hasattr(obj, "get_effective_name"): label = force_text(obj.get_effective_name(self.basket)) if self.basket and self.show_prices and hasattr( obj, "get_effective_taxless_price"): try: price = obj.get_effective_taxless_price(self.basket) if price: formatted_price = home_currency(price) label = "%s (%s)" % (label, formatted_price ) # TODO: Add tax handling. except: LOG.exception( "Unable to get or format method price for method %s" % obj) return label