From d2455ec82a78bff7c31c6884dfdafd6e28520ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 18 Feb 2023 21:44:19 +0100 Subject: [PATCH] Allow editing purchases --- games/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/games/views.py b/games/views.py index b6977cb..c2e632c 100644 --- a/games/views.py +++ b/games/views.py @@ -67,6 +67,18 @@ def edit_session(request, session_id=None): return render(request, "add.html", context) +def edit_purchase(request, purchase_id=None): + context = {} + purchase = Purchase.objects.get(id=purchase_id) + form = PurchaseForm(request.POST or None, instance=purchase) + if form.is_valid(): + form.save() + return redirect("list_sessions") + context["title"] = "Edit Purchase" + context["form"] = form + return render(request, "add.html", context) + + def start_session(request, last_session_id: int): last_session = Session.objects.get(id=last_session_id) session = SessionForm(