Ejemplo n.º 1
0
def signed_up():
    name = request.form["name"]
    budget = request.form["budget"]
    user = User(name, budget, id)
    user_repository.save(user)
    transactions = user_repository.select_transactions(user)
    return render_template("/users/first_visit.html",
                           user=user,
                           transactions=transactions)
Ejemplo n.º 2
0
def user_dashboard(id):
    user = user_repository.select(id)
    transactions = user_repository.select_transactions(user)
    total = 0
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html",
                           user=user,
                           total=total,
                           transactions=transactions)
Ejemplo n.º 3
0
def create_transaction():
    amount = request.form["amount"]
    user = user_repository.select(request.form["user"])
    merchant = merchant_repository.select(request.form["merchant"])
    tag = tag_repository.select(request.form["tag"])
    new_transaction = Transaction(amount, user, merchant, tag)
    transaction_repository.save(new_transaction)
    tags = tag_repository.select_all()
    transactions = user_repository.select_transactions(user)
    total = 0
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html", user = user, transactions = transactions, total = total, tags = tags)
Ejemplo n.º 4
0
def welcome():
    id = request.form["user.id"]
    user = user_repository.select(id)
    transactions = user_repository.select_transactions(user)
    total = 0
    tags = tag_repository.select_all()
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html",
                           user=user,
                           transactions=transactions,
                           tags=tags,
                           total=total)
Ejemplo n.º 5
0
def update_transaction(id):
    transaction = transaction_repository.select(id)
    user = user_repository.select(transaction.user.id)
    amount = request.form['amount']
    merchant = merchant_repository.select(request.form['merchant'])
    tag = tag_repository.select(request.form['tag'])
    updated_transaction = Transaction(amount, user, merchant, tag, transaction.id)
    transaction_repository.update(updated_transaction)
    transactions = user_repository.select_transactions(user)
    tags = tag_repository.select_all()
    total = 0
    for transaction in transactions:
        total += transaction.amount
    return render_template("/users/dashboard.html", user = user, transactions = transactions, total = total, tags = tags)