from django.shortcuts import render
import os.path
from users.models import Balance

def homePage(request):
    iter_var = 0
    all_balance = []

    try:
        balObject = Balance.objects.filter(user=request.user.id)
        userBalance = balObject.values("balanceValue")
        a = Balance.objects.all()
        for user in a:
            all_balance.append(user.balanceValue)
        print(f"{all_balance}")
        context = {
            "currencyTotal": sum(all_balance),
            "userBalance": userBalance[0]["balanceValue"]
        }

                
        return render(request, "home.html", context)
        

    except Exception as e:

        context = {
            "currencyTotal":e
        }
        return render(request, "home.html", context)