Add grid and list views for games with improved templates and routing

This commit is contained in:
Joakim Hellsén 2025-08-30 00:30:18 +02:00
commit ebd3633356
4 changed files with 40 additions and 4 deletions

View file

@ -1,12 +1,15 @@
{% extends "base.html" %}
{% block title %}
Games
Games - Grid View
{% endblock title %}
{% block content %}
<main>
<header>
<h1>All Games</h1>
<p>Browse all available games</p>
<p>
<a href="{% url 'twitch:game_list_simple' %}">List View</a>
</p>
</header>
{% if games_by_org %}
<section>

View file

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block title %}
Games - List View
{% endblock title %}
{% block content %}
<main>
<h1>Games List</h1>
<p>
<a href="{% url 'twitch:game_list' %}">Grid View</a>
</p>
{% if games_by_org %}
{% for organization, games in games_by_org.items %}
<h2>{{ organization.name }}</h2>
<ul style="list-style: none; padding: 0; margin: 0;">
{% for item in games %}
<li>
<a href="{% url 'twitch:game_detail' item.game.id %}">{{ item.game.display_name }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
{% else %}
<p>No games found.</p>
{% endif %}
</main>
{% endblock content %}

View file

@ -11,7 +11,8 @@ urlpatterns = [
path("debug/", views.debug_view, name="debug"),
path("campaigns/", views.DropCampaignListView.as_view(), name="campaign_list"),
path("campaigns/<str:pk>/", 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/<str:pk>/", views.GameDetailView.as_view(), name="game_detail"),
path("games/<str:game_id>/subscribe/", views.subscribe_game_notifications, name="subscribe_notifications"),
path("organizations/", views.OrgListView.as_view(), name="org_list"),

View file

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