From d447302b46641fe84abf463e62a2f5fd3b1f5f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 18 Feb 2023 20:50:36 +0100 Subject: [PATCH] Re-introduce index view --- games/urls.py | 8 +++++++- games/views.py | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/games/urls.py b/games/urls.py index dbb4239..bfc7dec 100644 --- a/games/urls.py +++ b/games/urls.py @@ -3,7 +3,13 @@ from django.urls import path from games import views urlpatterns = [ - path("", views.list_sessions, {"filter": "recent"}, name="list_sessions_recent"), + path("", views.index, name="index"), + path( + "list-sessions/recent", + views.list_sessions, + {"filter": "recent"}, + name="list_sessions_recent", + ), path("add-game/", views.add_game, name="add_game"), path("add-platform/", views.add_platform, name="add_platform"), path("add-session/", views.add_session, name="add_session"), diff --git a/games/views.py b/games/views.py index a78cd05..3ee787f 100644 --- a/games/views.py +++ b/games/views.py @@ -117,7 +117,7 @@ def add_purchase(request): form = PurchaseForm(request.POST or None, initial=initial) if form.is_valid(): form.save() - return redirect("list_sessions") + return redirect("index") context["form"] = form context["title"] = "Add New Purchase" @@ -129,7 +129,7 @@ def add_game(request): form = GameForm(request.POST or None) if form.is_valid(): form.save() - return redirect("list_sessions") + return redirect("index") context["form"] = form context["title"] = "Add New Game" @@ -153,8 +153,12 @@ def add_platform(request): form = PlatformForm(request.POST or None) if form.is_valid(): form.save() - return redirect("list_sessions") + return redirect("index") context["form"] = form context["title"] = "Add New Platform" return render(request, "add.html", context) + + +def index(request): + return redirect("list_sessions_recent")