mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
add a delete feature
This commit is contained in:
parent
03ce000e9a
commit
54de7abf23
2 changed files with 10 additions and 1 deletions
|
@ -125,6 +125,14 @@ def reset_bills():
|
|||
return redirect(url_for('list_bills'))
|
||||
|
||||
|
||||
@app.route("/delete/<int:bill_id>")
|
||||
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)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% block content %}
|
||||
{% if bills.count() > 0 %}
|
||||
<table>
|
||||
<thead><tr><th>When ?</th><th>Who paid?</th><th>for what ?</th><th>Owers</th><th>How much ?</th></tr></thead>
|
||||
<thead><tr><th>When ?</th><th>Who paid?</th><th>for what ?</th><th>Owers</th><th>How much ?</th><th>Actions</th></tr></thead>
|
||||
<tbody>
|
||||
{% for bill in bills %}
|
||||
<tr class="{{ loop.cycle("odd", "even") }}">
|
||||
|
@ -11,6 +11,7 @@
|
|||
<td>{{ bill.what }}</td>
|
||||
<td>{% for ower in bill.owers %}{{ ower.name }} {% endfor %}</td>
|
||||
<td>{{ bill.amount }} ({{ bill.pay_each() }} each)</td>
|
||||
<td><a href="{{ url_for("delete_bill", bill_id=bill.id) }}">delete</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue