Allow editing editions

This commit is contained in:
Lukáš Kucharczyk 2023-02-18 21:47:25 +01:00
parent 2eec677f41
commit 51d8e953c0
2 changed files with 13 additions and 0 deletions

View File

@ -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/<int:edition_id>", views.edit_edition, name="edit_edition"),
path("add-device/", views.add_device, name="add_device"),
path("edit-session/<int:session_id>", views.edit_session, name="edit_session"),
path("edit-purchase/<int:purchase_id>", views.edit_purchase, name="edit_purchase"),

View File

@ -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(