Python django.template.defaultfilters 模块,floatformat() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.template.defaultfilters.floatformat()

项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:ims    作者:ims-team    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:CSCE482-WordcloudPlus    作者:ggaytan00    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def get_description_deals(user, obj):
    order_id = obj.pk
    if not user == obj.user:
        if obj.el.sale.user == user:
            order_id = obj.el.sale.pk
        if obj.el.buy.user == user:
            order_id = obj.el.buy.pk
    if obj.w_action(user) == 'sale':
        return u"??????? {w_amo_sum_total} {left} ? ?????? ?????? #{pk} ?? ???? {rate} {right} ????? {w_total_total} {right} (-{commission}%)".format(**{
            "w_amo_sum_total": floatformat(obj.el._part_amo_sum, -8),
            "left": obj.el.pair.left,
            "pk": order_id,
            "rate": floatformat(obj.profitable.rate, -8),
            "right": obj.el.pair.right,
            "w_total_total": floatformat(obj.el._part_amo_sum * obj.el._rate, -8),
            #"w_total_total": floatformat(obj.el._part_amo_sum * obj.el._rate * (1 - obj.commission / D(100)), -8),
            "commission": obj.commission,
            })
    if obj.w_action(user) == 'buy':
        return u"??????? {w_amo_sum_total} {left} (-{commission}%) ? ?????? ?????? #{pk} ?? ???? {rate} {right}".format(**{
            "w_amo_sum_total": floatformat(obj.el._part_amo_sum, -8),
            #"w_amo_sum_total": floatformat(obj.el._part_amo_sum * (1 - obj.commission / D(100)), -8),
            "left": obj.el.pair.left,
            "pk": order_id,
            "rate": floatformat(obj.profitable.rate, -8),
            "right": obj.el.pair.right,
            "commission": obj.commission,
            })
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def get_total_deals(user, obj):
    order_id = obj.pk
    if not user == obj.user:
        if obj.el.sale.user == user:
            order_id = obj.el.sale.pk
        if obj.el.buy.user == user:
            order_id = obj.el.buy.pk
    if obj.w_action(user) == 'sale':
        return u"+{w_total_total} {right}".format(**{
            "w_amo_sum_total": floatformat(obj.el._part_amo_sum, -8),
            "left": obj.el.pair.left,
            "pk": order_id,
            "rate": floatformat(obj.profitable.rate, -8),
            "right": obj.el.pair.right,
            "w_total_total": floatformat(obj.el._part_amo_sum * obj.el._rate * (1 - obj.commission / D(100)), -8),
            "commission": obj.commission,
            })
    if obj.w_action(user) == 'buy':
        return u"+{w_total_total} {left}".format(**{
            "w_amo_sum_total": floatformat(obj.el._part_amo_sum * (1 - obj.commission / D(100)), -8),
            "left": obj.el.pair.left,
            "pk": order_id,
            "rate": floatformat(obj.profitable.rate, -8),
            "right": obj.el.pair.right,
            "w_total_total": floatformat(obj.el._part_amo_sum * (1 - obj.commission / D(100)), -8),
            "commission": obj.commission,
            })
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def get_commission(obj):
    flr={}
    if obj.get('valuta_id'): flr.update({"valuta":obj.get('valuta_id')})
    if obj.get('paymethod_id'): flr.update({"paymethod":obj.get('paymethod_id')})
    if obj.get('action'): flr.update({"action":obj.get('action')})
    return floatformat(ProfileBalance.sum_commission(flr), -8)
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def commiss(self):
        return floatformat(normalized(self._commission_debit), -8)
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def sum_order_current(self):
        if self.is_action('sale'): res = self.sale._sum_ret
        if self.is_action('buy'): res = self.buy._ret_amount
        return floatformat(res, -8)
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def order(request, form):
    dajax = Dajax()
    q=deserialize_form(form)
    ttype = ''
    if not q.get('buy-amount', None) is None: ttype = 'buy'
    if not q.get('sale-amount', None) is None: ttype = 'sale'
    form = OrdersForm(prefix=ttype, data=q)
    if form.is_valid():
        c=form.cleaned_data
        user=request.user
        if user.is_authenticated() and user.is_active:
            pair, amount, rate = c.get('pair'), c.get('amount'), c.get('rate')
            total, commission, pos = pair.calc(amount, rate, ttype)
            if ttype == 'buy': pos = pair.right
            if ttype == 'sale': pos = pair.left
            valuta = pos.value
            balance = user.orders_balance(valuta)
            if ttype == 'buy': _sum = balance - total
            if ttype == 'sale': _sum = balance - amount
            if _sum >= 0:
                _ret = getattr(pair, "order_%s" % ttype)(user, amount, rate)
                dajax.remove_css_class('#{type}_form input'.format(**{"type":ttype}), 'error')
                dajax.script("location.reload();")
            else:
                text = "????? ?????? ????????? ??? ?????? ?? {sum} {valuta}".format(**{"sum":floatformat(-_sum, -8), "valuta": pos })
                dajax.script("$('#info_{type}').text('{text}');".format(**{"type":ttype, "text":text, }))
        else:
            pair, amount, rate = c.get('pair'), c.get('amount'), c.get('rate')
            total, commission, pos = pair.calc(amount, rate, ttype)
            if ttype == 'buy': _sum = total
            if ttype == 'sale': _sum = amount
            text = "????? ?????? ????????? ??? ?????? ?? {sum} {valuta}".format(**{"sum":floatformat(-_sum, -8), "valuta": pos })
            dajax.script("$('#info_{type}').text('{text}');".format(**{"type":ttype, "text":text, }))
    else:
        dajax.script("$('#info_{type}').text('{text}');".format(**{"type":ttype, "text":"??????????? ????????? ???? ?? ?????.", }))
        for error in form.errors:
            dajax.add_css_class('#id_%s-%s' % (ttype, error), 'error')
    return dajax.json()
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def calc_paymethod(request, value, paymethod, act="-"):
    dajax = Dajax()
    v = get_object_or_404(PaymentMethod, pk=paymethod, disable=False)
    calc_value = v.calc_commission(D(value))
    calc_value1 = v.calc_commission(D(value), True)
    if act == "-":
        dajax.assign('#calc-value-result', 'value', floatformat(calc_value, -8).replace(",", "."))
    else:
        dajax.assign('#balance-value', 'value', floatformat(calc_value1, -8).replace(",", "."))
        dajax.assign('#calc-value-result', 'value', floatformat(value, -8).replace(",", "."))
    return dajax.json()
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def w_min_commission(self):
        return u"???. {amount} {valuta}".format(**{ "amount":floatformat(self.min_commission, -8), "valuta":self.valuta })
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def w_max_commission(self):
        return u"????. {amount} {valuta}".format(**{ "amount":floatformat(self.max_commission, -8), "valuta":self.valuta })
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def w_commission(self):
        if self.commission > _Zero:
            return u"{commission}% ".format(**{"commission": floatformat(self.commission, -2)})
        return ""
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def commission_records_orders(self):
        for v in Valuta.objects.all():
            yield v, floatformat(Orders.sum_from_commission(v.value), -8), v.pk
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def commission_records(self):
        for v in Valuta.objects.all():
            yield v, floatformat(self._commission_records(v.value), -8), v.pk
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def balance_left(self):
        return mark_safe("<span>{amo}<span> {pos}".format(**{"amo":floatformat(self.amount_left, -8), "pos":self.pair.left}))
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def balance_right(self):
        return mark_safe("<span>{amo}</span> {pos}".format(**{"amo":floatformat(self.amount_right, -8), "pos":self.pair.right}))
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def w_total_transaction(self):
        return "%s%s %s" % (self.action, floatformat(self._total_transaction, -8), self.valuta)
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def w_commission(self):
        if self.min_commission > _Zero and (self.value * self.commission / D(100)) < self.min_commission:
            return u"{commission} {valuta}".format(**{"commission":floatformat(self.min_commission, -8), "valuta": self.valuta})
        elif self.max_commission > _Zero and (self.value * self.commission / D(100)) > self.max_commission:
            return u"{commission} {valuta}".format(**{"commission":floatformat(self.max_commission, -8), "valuta": self.valuta})
        else:
            return u"{commission}%".format(**{"commission":self.commission,})
项目:extrade    作者:aza7    | 项目源码 | 文件源码
def total_admin(self):
        v = normalized(self.value - self._commission_debit, where="DOWN")
        return floatformat(v, -8)
项目:producthunt    作者:davidgengler    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:geekpoint    作者:Lujinghu    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def get_percentage(self, obj):
        return floatformat(obj['share']*100, -2)
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def get_display_share(self, obj):
        return floatformat(obj['share']*100)
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def display_fee(self, amount=None):
        if amount is None:
            amount = self.pay
        if not amount:
            return ''
        if self.currency in CURRENCY_SYMBOLS:
            return '{}{}'.format(CURRENCY_SYMBOLS[self.currency], floatformat(amount, arg=-2))
        return amount or ''
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def display_fee(self, amount=None):
        if amount is None:
            amount = self.fee
        if self.currency in CURRENCY_SYMBOLS:
            return '{}{}'.format(CURRENCY_SYMBOLS[self.currency], floatformat(amount, arg=-2))
        return amount or ''
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def handle(self, *args, **options):
        """
        Update periodic update events and send notifications for upcoming update events.
        """
        # command to run: python manage.py tunga_export_payments

        participant_payments = ParticipantPayment.objects.filter(participant__task__paid=True)

        print('participant_payments', len(participant_payments))
        with open('developer_payments.csv', 'wb') as csvfile:
            spamwriter = csv.writer(csvfile, delimiter=',',
                                    quotechar='"', quoting=csv.QUOTE_MINIMAL)
            spamwriter.writerow([
                'Task', 'Fee', 'Developer', 'Dev BTC Address', 'BTC Sent', 'Task BTC Address', 'Invoice Date',
                'Paid By', 'URL', 'Developer Invoice', 'Client Invoice'
            ])

            for payment in participant_payments:
                row = [
                    payment.participant.task.summary, 'EUR {}'.format(floatformat(payment.participant.task.fee, -2)),
                    payment.participant.user.display_name, payment.destination,
                    'BTC {}'.format(floatformat(payment.btc_sent, -6)), payment.participant.task.btc_address,
                    payment.participant.task.taskinvoice_set.first().created_at.strftime("%d %b, %Y"),
                    payment.participant.task.user.display_name,
                    '{}/work/{}'.format(TUNGA_URL, payment.participant.task.id),
                    '{}/api/task/{}/download/invoice/?format=pdf&type=developer'.format(TUNGA_URL, payment.participant.task.id),
                    '{}/api/task/{}/download/invoice/?format=pdf&type=client'.format(TUNGA_URL, payment.participant.task.id)
                ]
                spamwriter.writerow(row)
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def intword(value):
    """
    Converts a large integer to a friendly text representation. Works best
    for numbers over 1 million. For example, 1000000 becomes '1.0 million',
    1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
    """
    try:
        value = int(value)
    except (TypeError, ValueError):
        return value

    if value < 1000000:
        return value

    def _check_for_i18n(value, float_formatted, string_formatted):
        """
        Use the i18n enabled defaultfilters.floatformat if possible
        """
        if settings.USE_L10N:
            value = defaultfilters.floatformat(value, 1)
            template = string_formatted
        else:
            template = float_formatted
        return template % {'value': value}

    for exponent, converters in intword_converters:
        large_number = 10 ** exponent
        if value < large_number * 1000:
            new_value = value / float(large_number)
            return _check_for_i18n(new_value, *converters(new_value))
    return value