def remove_budget(id):
""" Remove a budget from the database """
# This is the budget object we are working with
budget_at_hand = Budget.query.filter_by(id=id).first()
# This is the user id of the user in the session
user_id = session.get('id')
# Check to make sure the budget is associated with the logged in user
if user_id == budget_at_hand.budget_userid:
# Deletes the budget item from the budget table
db.session.delete(budget_at_hand)
db.session.commit()
# Redirect the user to their dashboard
return redirect(url_for('dashboard', id=user_id))
评论列表
文章目录