Beispiel #1
0
    def test_different_args_not_cached_together(self):
        times_called = [0]
        def wrap_this_func(x):
            times_called[0] += 1

        cached(wrap_this_func)("something")
        cached(wrap_this_func)("something else")

        self.assertEqual(times_called[0], 2)
Beispiel #2
0
    def test_function_not_called_twice(self):
        times_called = [0]
        def wrap_this_func():
            times_called[0] += 1

        cached(wrap_this_func)()
        cached(wrap_this_func)()

        self.assertEqual(times_called[0], 1)
Beispiel #3
0
def home_page(request):
    messageform = MsgBoxForm()
    response = {
        "title": "Exchanger",
        "coins": cached(getcoins)(),
        "dollar": cached(getdollar)(),
        "MsgForm": messageform
    }
    return render(request, "home.html", context=response)
Beispiel #4
0
    def test_expiry_time(self):
        times_called = [0]
        def wrap_this_func():
            times_called[0] += 1

        cached(wrap_this_func, seconds=1)()
        sleep(1.5)
        cached(wrap_this_func, seconds=1)()

        self.assertEqual(times_called[0], 2)
Beispiel #5
0
def coinswithamount(request, coin):
    coins = cached(getcoins)()
    for k in coins["data"]:
        if int(k["rank"]) <= 20:
            if k["symbol"] == coin:
                return JsonResponse({
                    'coin': coin,
                    'USD': k["priceUsd"],
                    'IRR': cached(getdollar)()
                })
    return HttpResponse("I Cant Found Your Coin")
Beispiel #6
0
def coinsselector():
    response = []
    response.append(('USD', 'USD'))
    response.append(('IRR', 'IRR'))
    coins = cached(getcoins)()
    for i in coins["data"]:
        if int(i["rank"]) <= 20:
            response.append((i["symbol"], i["symbol"]))
    return response
Beispiel #7
0
    def test_cache_returns_correct_value(self):
        def wrap_this_func():
            return "foo"

        self.assertEqual(cached(wrap_this_func)(), "foo")
Beispiel #8
0
def dashboard_page(request):
    verified = Verification.objects.filter(user=request.user).first()
    if verified:
        verified = verified.is_verified
    else:
        verified = False
    ######################## Card Form Place Holders ################
    card_form = cardForm()
    card_form.fields['card_number'].widget.attrs.update(
        {'placeholder': 'CardNumber'})
    card_form.fields['date_exp'].widget.attrs.update(
        {'placeholder': 'Date Of EXP'})
    card_form.fields['cvv'].widget.attrs.update({'placeholder': 'CVV'})
    card_form.fields['card_front'].widget.attrs.update(
        {'placeholder': 'Card Front Side'})
    card_form.fields['card_back'].widget.attrs.update(
        {'placeholder': 'Card Back Side'})
    ######################## Verification Form Place Holders ################
    verification_form = VerificationForm()
    verification_form.fields['passport_code'].widget.attrs.update(
        {'placeholder': 'Passport Code'})
    verification_form.fields['country_name'].widget.attrs.update(
        {'placeholder': 'Country Name'})
    verification_form.fields['birth_date'].widget.attrs.update(
        {'placeholder': 'Date of Birth'})
    verification_form.fields['address'].widget.attrs.update(
        {'placeholder': 'Address'})
    verification_form.fields['passport_photo'].widget.attrs.update(
        {'placeholder': 'Passport Photo'})
    ######################## Order Form Place Holders ################
    order_form = OrderForm(cards=request.user, coins=coinsselector())
    order_form.fields['receipt_code'].widget.attrs.update(
        {'id': 'nextstep123'})
    # order_form.fields['receipt_code'].widget.attrs.update({'style': 'display:none;'})
    order_form.fields['blockchain_wallet'].widget.attrs.update(
        {'id': 'nextstep1234'})
    order_form.fields['source_amount'].widget.attrs.update(
        {'onchange': 'setamount()'})
    order_form.fields['source_currency'].widget.attrs.update(
        {'onchange': 'setamount()'})
    order_form.fields['destination_currency'].widget.attrs.update(
        {'onchange': 'setamount()'})
    ######################## ProfileUpdate ##########################
    profile_form = ProfileForm()
    profile_form.fields['first_name'].widget.attrs.update(
        {"value": request.user.first_name})
    profile_form.fields['last_name'].widget.attrs.update(
        {"value": request.user.last_name})
    phone_number = UserProfile.objects.filter(
        user=request.user).first().phone_number
    profile_form.fields['phone_number'].widget.attrs.update(
        {"value": phone_number})
    ######################## End ################
    orders = Order.objects.filter(user=request.user)
    response = {
        "title": "Dashboard",
        "coins": cached(getcoins)(),
        "dollar": cached(getdollar)(),
        "card_form": card_form,
        "Verification_Form": verification_form,
        "orders": orders,
        "Order_Form": order_form,
        "ProfileForm": profile_form,
        "is_verified": verified
    }
    print(response)
    return render(request, "panel/dashboard.html", context=response)