From ebd3633356c796ad1ff187715ca1c953b3da5110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sat, 30 Aug 2025 00:30:18 +0200 Subject: [PATCH] Add grid and list views for games with improved templates and routing --- .../{game_list.html => games_grid.html} | 5 +++- templates/twitch/games_list.html | 26 +++++++++++++++++++ twitch/urls.py | 3 ++- twitch/views.py | 10 +++++-- 4 files changed, 40 insertions(+), 4 deletions(-) rename templates/twitch/{game_list.html => games_grid.html} (95%) create mode 100644 templates/twitch/games_list.html diff --git a/templates/twitch/game_list.html b/templates/twitch/games_grid.html similarity index 95% rename from templates/twitch/game_list.html rename to templates/twitch/games_grid.html index b05992d..f9e7775 100644 --- a/templates/twitch/game_list.html +++ b/templates/twitch/games_grid.html @@ -1,12 +1,15 @@ {% extends "base.html" %} {% block title %} - Games + Games - Grid View {% endblock title %} {% block content %}

All Games

Browse all available games

+

+ List View +

{% if games_by_org %}
diff --git a/templates/twitch/games_list.html b/templates/twitch/games_list.html new file mode 100644 index 0000000..963b647 --- /dev/null +++ b/templates/twitch/games_list.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} +{% block title %} + Games - List View +{% endblock title %} +{% block content %} +
+

Games List

+

+ Grid View +

+ {% if games_by_org %} + {% for organization, games in games_by_org.items %} +

{{ organization.name }}

+ + {% endfor %} + {% else %} +

No games found.

+ {% endif %} +
+{% endblock content %} diff --git a/twitch/urls.py b/twitch/urls.py index 42855e2..57dc6a6 100644 --- a/twitch/urls.py +++ b/twitch/urls.py @@ -11,7 +11,8 @@ urlpatterns = [ path("debug/", views.debug_view, name="debug"), path("campaigns/", views.DropCampaignListView.as_view(), name="campaign_list"), path("campaigns//", views.DropCampaignDetailView.as_view(), name="campaign_detail"), - path("games/", views.GameListView.as_view(), name="game_list"), + path("games/", views.GamesGridView.as_view(), name="game_list"), + path("games/list/", views.GamesListView.as_view(), name="game_list_simple"), path("games//", views.GameDetailView.as_view(), name="game_detail"), path("games//subscribe/", views.subscribe_game_notifications, name="subscribe_notifications"), path("organizations/", views.OrgListView.as_view(), name="org_list"), diff --git a/twitch/views.py b/twitch/views.py index 321fdc3..aaa5499 100644 --- a/twitch/views.py +++ b/twitch/views.py @@ -154,11 +154,11 @@ class DropCampaignDetailView(DetailView): return context -class GameListView(ListView): +class GamesGridView(ListView): """List view for games grouped by organization.""" model = Game - template_name = "twitch/game_list.html" + template_name = "twitch/games_grid.html" context_object_name = "games" def get_queryset(self) -> QuerySet[Game]: @@ -500,3 +500,9 @@ def subscribe_org_notifications(request: HttpRequest, org_id: str) -> HttpRespon messages.warning(request, "Only POST is available for this view.") return redirect("twitch:organization_detail", pk=organization.id) + + +class GamesListView(GamesGridView): + """List view for games in simple list format.""" + + template_name = "twitch/games_list.html"