示例#1
0
    def label_from_instance(self, obj):
        """Return a friendly label for the shipping method."""
        price_html = format_price(obj.price.gross, obj.price.currency)
        min_delivery_time = str(obj.min_delivery_time)
        max_delivery_time = str(obj.max_delivery_time)

        label = mark_safe(
            'Courier: %s | Price: %s | Estimated time: %s - %s days' %
            (obj.shipping_method, price_html, min_delivery_time,
             max_delivery_time))
        return label
示例#2
0
 def label_from_instance(self, obj):
     """Return a friendly label for the shipping method."""
     price_html = format_price(obj.price.gross, obj.price.currency)
     label = mark_safe('%s %s' % (obj.shipping_method, price_html))
     return label
示例#3
0
def test_normalize_same_as_formatted(value):
    formatted_price = prices_i18n.format_price(value, 'USD', normalize=True)
    net = prices_i18n.net(Price(net=value, currency='USD'))
    assert not formatted_price == net
示例#4
0
def test_format_normalize_price_three_digits(value, expected):
    normalized_price = prices_i18n.format_price(value, 'BHD', normalize=True)
    assert normalized_price == expected
示例#5
0
def test_format_normalize_price_no_digits():
    formatted_price = prices_i18n.format_price(123, 'JPY', normalize=True)
    assert formatted_price == '¥123'
示例#6
0
def test_format_normalize_price(value, expected):
    formatted_price = prices_i18n.format_price(value, 'USD', normalize=True)
    assert formatted_price == '$%s' % expected
示例#7
0
def test_format_price_invalid_value():
    result = prices_i18n.format_price("invalid", "USD")
    assert result == ""
示例#8
0
 def label_from_instance(self, obj):
     price_html = format_price(obj.price.gross, obj.price.currency)
     label = mark_safe('%s %s' % (obj.shipping_method, price_html))
     return label
示例#9
0
def test_format_price_invalid_value():
    result = prices_i18n.format_price('invalid', 'USD')
    assert result == ''
示例#10
0
文件: forms.py 项目: patrys/saleor
 def label_from_instance(self, obj):
     """Return a friendly label for the shipping method."""
     price_html = format_price(obj.price.gross, obj.price.currency)
     label = mark_safe('%s %s' % (obj.shipping_method, price_html))
     return label
示例#11
0
def test_format_price_invalid_value():
    result = prices_i18n.format_price('invalid', 'USD')
    assert result == ''
示例#12
0
 def label_from_instance(self, obj):
     # Mexer aqui para API de Correios
     price_html = format_price(obj.price.gross, obj.price.currency)
     label = mark_safe('%s' % (obj.shipping_method))
     return label
示例#13
0
def format_price(value: Decimal, currency=None, html=False, normalize=False):
    return prices_i18n.format_price(value,
                                    currency=currency
                                    or settings.DEFAULT_CURRENCY,
                                    html=html,
                                    normalize=normalize)