From a05e0e0fa34df4d109fff051e95fba8e6b895b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 18 Feb 2023 21:47:25 +0100 Subject: [PATCH] Allow editing editions --- games/urls.py | 1 + games/views.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/games/urls.py b/games/urls.py index f97593e..0e276af 100644 --- a/games/urls.py +++ b/games/urls.py @@ -30,6 +30,7 @@ urlpatterns = [ ), path("add-purchase/", views.add_purchase, name="add_purchase"), path("add-edition/", views.add_edition, name="add_edition"), + path("edit-edition/", views.edit_edition, name="edit_edition"), path("add-device/", views.add_device, name="add_device"), path("edit-session/", views.edit_session, name="edit_session"), path("edit-purchase/", views.edit_purchase, name="edit_purchase"), diff --git a/games/views.py b/games/views.py index c2e632c..990e9ea 100644 --- a/games/views.py +++ b/games/views.py @@ -79,6 +79,18 @@ def edit_purchase(request, purchase_id=None): return render(request, "add.html", context) +def edit_edition(request, edition_id=None): + context = {} + edition = Edition.objects.get(id=edition_id) + form = EditionForm(request.POST or None, instance=edition) + if form.is_valid(): + form.save() + return redirect("list_sessions") + context["title"] = "Edit Edition" + 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(