コード例 #1
0
def add_credit(user, value, address=None, free=False):
    value = float(value)

    if not address and not free:
        address = user.address_set.filter(removed=False).get(default=True)

    credit = Credit()
    if not free:
        credit.date_payed = None
    else:
        credit.date_payed = datetime.now()
    print config.credit_currency
    credit.user = user
    credit.price = (1 / float(config.credit_quotient)) * value
    credit.currency = config.credit_currency
    credit.value = value
    credit.bonus = 0
    credit.address = address
    credit.save()

    if address and not free:
        context = {
            "cost": credit.price,
            "currency": credit.currency,
            "bank": config.bank_name,
            "bank_account": config.bank_account,
            "var_symbol": user.parms.var_symbol,
        }
        msg = Message.objects.get(purpose="make_a_payment")
        msg.send(address.email, context)

    return credit
コード例 #2
0
ファイル: tools.py プロジェクト: masterdubs/pcp
def add_credit(user, value, address=None, free=None):
    value = float(value)

    if not address and not free:
        address = user.address_set.filter(removed=False).get(default=True)

    credit = Credit()
    if not free:
        credit.date_payed = None
    else:
        credit.date_payed = datetime.now()
    print config.credit_currency
    credit.user = user
    credit.price = (1 / float(config.credit_quotient)) * value
    credit.currency = config.credit_currency
    credit.value = value
    credit.bonus = 0
    credit.address = address
    credit.save()

    if address and not free:
        context = {
            "cost": credit.price,
            "currency": credit.currency,
            "bank": config.bank_name,
            "bank_account": config.bank_account,
            "var_symbol": user.parms.var_symbol,
            }
        msg = Message.objects.get(purpose="make_a_payment")
        msg.send(address.email, context)

    return credit
コード例 #3
0
def add_credit(user, value, address=None, free=None):
    bonus = 1.0
    value = float(value)

    if value >= 1000:
        bonus = config.credit_1000_bonus
    elif value >= 750:
        bonus = config.credit_750_bonus
    elif value >= 500:
        bonus = config.credit_500_bonus
    elif value >= 250:
        bonus = config.credit_250_bonus

    if not address and not free:
        address = user.address_set.get(default=True)

    credit = Credit()
    if not free:
        credit.date_payed = None
    else:
        credit.date_payed = datetime.now()
    credit.user = user
    credit.price = (1 / float(config.credit_currency.split(",")[0])) * value
    credit.currency = "CZK"
    credit.value = value * bonus
    credit.bonus = value * (bonus - 1.0)
    credit.address = address
    credit.save()

    return credit, bonus
コード例 #4
0
ファイル: tools.py プロジェクト: seanchen/pcp
def add_credit(user, value, address=None, free=None):
    bonus = 1.0
    value = float(value)

    if value >= 1000:
        bonus = config.credit_1000_bonus
    elif value >= 750:
        bonus = config.credit_750_bonus
    elif value >= 500:
        bonus = config.credit_500_bonus
    elif value >= 250:
        bonus = config.credit_250_bonus

    if not address and not free:
        address = user.address_set.get(default=True)

    credit = Credit()
    if not free:
        credit.date_payed = None
    else:
        credit.date_payed = datetime.now()
    credit.user = user
    credit.price = (1 / float(config.credit_currency.split(",")[0])) * value
    credit.currency = "CZK"
    credit.value = value * bonus
    credit.bonus = value * (bonus - 1.0)
    credit.address = address
    credit.save()

    return credit, bonus