nowa funckcja i male zmiany w js

This commit is contained in:
Mateusz Gruszczyński
2025-07-18 10:45:51 +02:00
parent 45290a6147
commit 804b80bbf5
5 changed files with 94 additions and 5 deletions

15
app.py
View File

@@ -610,6 +610,21 @@ def edit_my_list(list_id):
return render_template("edit_my_list.html", list=l)
@app.route("/delete_user_list/<int:list_id>", methods=["POST"])
@login_required
def delete_user_list(list_id):
l = db.session.get(ShoppingList, list_id)
if l is None or l.owner_id != current_user.id:
abort(403)
delete_receipts_for_list(list_id)
Item.query.filter_by(list_id=list_id).delete()
Expense.query.filter_by(list_id=list_id).delete()
db.session.delete(l)
db.session.commit()
flash("Lista została usunięta", "success")
return redirect(url_for("main_page"))
@app.route("/toggle_visibility/<int:list_id>", methods=["GET", "POST"])
@login_required
def toggle_visibility(list_id):