From 54de7abf23f61df916fe65f590d0d45ec8e2d174 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Fri, 18 Mar 2011 19:44:40 +0000 Subject: [PATCH] add a delete feature --- budget/budget.py | 8 ++++++++ budget/templates/list_bills.html | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/budget/budget.py b/budget/budget.py index e22b053..6a579f1 100644 --- a/budget/budget.py +++ b/budget/budget.py @@ -125,6 +125,14 @@ def reset_bills(): return redirect(url_for('list_bills')) +@app.route("/delete/") +def delete_bill(bill_id): + Bill.query.filter(Bill.id == bill_id).delete() + BillOwer.query.filter(BillOwer.bill_id == bill_id).delete() + db.session.commit() + flash("the bill was deleted") + + return redirect(url_for('list_bills')) if __name__ == '__main__': app.run(host="0.0.0.0", debug=True) diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index fba328e..09caa48 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -2,7 +2,7 @@ {% block content %} {% if bills.count() > 0 %} - + {% for bill in bills %} @@ -11,6 +11,7 @@ + {% endfor %}
When ?Who paid?for what ?OwersHow much ?
When ?Who paid?for what ?OwersHow much ?Actions
{{ bill.what }} {% for ower in bill.owers %}{{ ower.name }} {% endfor %} {{ bill.amount }} ({{ bill.pay_each() }} each)delete