From 15997bd5af6b5f5c42997d9e0ed6ee18321393c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 3 Jun 2024 18:07:10 +0200 Subject: [PATCH] Re-enable delete session delete view --- games/urls.py | 10 +++++----- games/views.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/games/urls.py b/games/urls.py index 93b6e34..d00f77f 100644 --- a/games/urls.py +++ b/games/urls.py @@ -42,11 +42,11 @@ urlpatterns = [ {"template": "list_sessions.html#session-row"}, name="list_sessions_end_session", ), - # path( - # "session//delete", - # views.delete_session, - # name="delete_session", - # ), + path( + "session//delete", + views.delete_session, + name="delete_session", + ), path( "purchase//delete", views.delete_purchase, diff --git a/games/views.py b/games/views.py index 4940ad8..192beab 100644 --- a/games/views.py +++ b/games/views.py @@ -283,11 +283,11 @@ def end_session(request, session_id: int, template: str = ""): return render(request, template, context) return redirect("list_sessions") - -# def delete_session(request, session_id=None): -# session = Session.objects.get(id=session_id) -# session.delete() -# return redirect("list_sessions") +@login_required +def delete_session(request, session_id=None): + session = get_object_or_404(Session, id=session_id) + session.delete() + return redirect("list_sessions") @login_required