Beispiel #1
0
def crypto_currency_withdraw(Req, CurrencyTitle):

    Dict = {}
    CurrencyIn = Currency.objects.get(title=CurrencyTitle)
    Dict["currency"] = CurrencyTitle
    Dict["use_f2a"] = False
    if Req.session.has_key("use_f2a"):
        Dict["use_f2a"] = Req.session["use_f2a"]

    t = loader.get_template("ajax_form.html")
    Dict["action"] = "/finance/crypto_currency_withdraw_submit"
    Dict["action_title"] = settings.withdraw_transfer

    try:
        Last = CryptoTransfers.objects.filter(user=Req.user, currency=CurrencyIn, status="processed").order_by("-id")[0]
    #         Dict["wallet"] = Last.account
    except:
        pass

    TradePair = TradePairs.objects.get(currency_on=CurrencyIn, currency_from=CurrencyIn)
    Dict["common_help_text"] = settings.attention_be_aware_crypto % (str(TradePair.min_trade_base))

    Form = CurrencyTransferForm(initial=Dict, user=Req.user)

    Dict["form"] = Form.as_p()
    return tmpl_context(Req, t, Dict)
Beispiel #2
0
def crypto_currency_withdraw(Req, CurrencyTitle):
    Dict = {}
    CurrencyIn = Currency.objects.get(title=CurrencyTitle)
    Dict["currency"] = CurrencyTitle
    Dict["use_f2a"] = False
    if Req.session.has_key("use_f2a"):
        Dict["use_f2a"] = Req.session["use_f2a"]

    t = loader.get_template("ajax_form.html")
    Dict["action"] = "/finance/crypto_currency_withdraw_submit"
    Dict["action_title"] = settings.withdraw_transfer

    try:
        Last = CryptoTransfers.objects.filter(user=Req.user, currency=CurrencyIn, status="processed").order_by('-id')[0]
        #         Dict["wallet"] = Last.account
    except:
        pass

    TradePair = TradePairs.objects.get(currency_on=CurrencyIn,
                                       currency_from=CurrencyIn)
    Dict["common_help_text"] = settings.attention_be_aware_crypto % ( str(TradePair.min_trade_base) )

    Form = CurrencyTransferForm(initial=Dict, user=Req.user)

    Dict["form"] = Form.as_p()
    return tmpl_context(Req, t, Dict)
Beispiel #3
0
def crypto_currency_withdraw_submit(Req):
    
    
    Dict = {"use_f2a": False}     
    
    if Req.session.has_key("use_f2a"):
             Dict["use_f2a"] =  Req.session["use_f2a"]
            
    Form = CurrencyTransferForm(data = Req.POST, user = Req.user )  
    getcontext().prec = settings.TRANS_PREC
    
    if Form.is_valid():
        # Save 
        Key = generate_key("currency_withdraw")
                
        Amnt  = Decimal(Form.cleaned_data["amnt"]) - Form.comission

        transfer = CryptoTransfers(
                                 account = Form.cleaned_data["wallet"],
                                 currency = Form.currency_instance,
                                 amnt = Amnt,
                                 comission = Form.comission,
                                 user = Req.user,
                                 confirm_key = Key,
                                 debit_credit = "out"
                              )
        transfer.save()
        
        #if settings.DEBUG is False:        
        send_mail(_(u'Подтверждение вывода  ') + settings.BASE_HOST,
                                    confirm_crypto_withdraw_email(Form.cleaned_data, Key),
                                    settings.EMAIL_HOST_USER,
                                   [ Req.user.email ],
                                     fail_silently = False)  
        
        return redirect("/finance/confirm_withdraw_msg")                
    else :
        t = loader.get_template("simple_form.html")   
        Dict["form"] = Form.as_p()
        CurrencyIn = Currency.objects.get(title = Form.cleaned_data["currency"]) 
        
        Dict["currency"] = Form.cleaned_data["currency"]
        TradePair = TradePairs.objects.get(currency_on = CurrencyIn,
                                           currency_from  = CurrencyIn )      
        Dict["common_help_text"] = settings.attention_be_aware_crypto % ( str(TradePair.min_trade_base) )        
        Dict["action"] = "/finance/crypto_currency_withdraw_submit"
        Dict["action_title"] = settings.withdraw_transfer        
        Dict["pin_load"] = not Dict["use_f2a"]
        return tmpl_context(Req, t, Dict)
Beispiel #4
0
def crypto_currency_withdraw_submit(Req):
    Dict = {"use_f2a": False}
    if Req.session.has_key("use_f2a"):
        Dict["use_f2a"] = Req.session["use_f2a"]
    Form = CurrencyTransferForm(data=Req.POST, user=Req.user)
    getcontext().prec = settings.TRANS_PREC

    if Form.is_valid():
        # Save 
        Key = generate_key("currency_withdraw")
        Amnt = Decimal(Form.cleaned_data["amnt"]) - Form.comission
        transfer = CryptoTransfers(account=Form.cleaned_data["wallet"],
                                   currency=Form.currency_instance,
                                   amnt=Amnt,
                                   pub_date=datetime.datetime.now(),
                                   comission=Form.comission,
                                   user=Req.user,
                                   confirm_key=Key,
                                   debit_credit="out")
        transfer.save()
        #if settings.DEBUG is False:
        send_mail(_(u'Подтверждение вывода  ') + settings.BASE_HOST,
                  confirm_crypto_withdraw_email(Form.cleaned_data, Key),
                  [Req.user.email],
                  fail_silently=False)

        return redirect("/finance/confirm_withdraw_msg")
    else:
        t = loader.get_template("simple_form.html")
        Dict["form"] = Form.as_p()
        CurrencyIn = Currency.objects.get(title=Form.cleaned_data["currency"])

        Dict["currency"] = Form.cleaned_data["currency"]
        TradePair = TradePairs.objects.get(currency_on=CurrencyIn,
                                           currency_from=CurrencyIn)
        Dict["common_help_text"] = settings.attention_be_aware_crypto % ( str(TradePair.min_trade_base) )
        Dict["action"] = "/finance/crypto_currency_withdraw_submit"
        Dict["action_title"] = settings.withdraw_transfer
        Dict["pin_load"] = not Dict["use_f2a"]
        return tmpl_context(Req, t, Dict)