From 4b1329befb98d04c5575999aaaead9d05bbf2847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Wed, 3 Sep 2025 17:14:41 +0200 Subject: [PATCH] Add JSON serialization for game data in game detail view --- templates/twitch/game_detail.html | 1 + twitch/views.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/templates/twitch/game_detail.html b/templates/twitch/game_detail.html index e93f068..1804516 100644 --- a/templates/twitch/game_detail.html +++ b/templates/twitch/game_detail.html @@ -84,4 +84,5 @@ {% if not active_campaigns and not upcoming_campaigns and not expired_campaigns %} No campaigns found for this game. {% endif %} +
{{ game_data }}
{% endblock content %} diff --git a/twitch/views.py b/twitch/views.py index c1c636d..eb91885 100644 --- a/twitch/views.py +++ b/twitch/views.py @@ -291,6 +291,20 @@ class GameDetailView(DetailView): expired_campaigns: list[DropCampaign] = [campaign for campaign in all_campaigns if campaign.end_at is not None and campaign.end_at < now] + serialized_game = serialize( + "json", + [game], + fields=( + "slug", + "name", + "display_name", + "box_art", + "owner", + ), + ) + game_data = json.loads(serialized_game) + pretty_game_data = json.dumps(game_data[0], indent=4) + context.update({ "active_campaigns": active_campaigns, "upcoming_campaigns": upcoming_campaigns, @@ -298,6 +312,7 @@ class GameDetailView(DetailView): "subscription": subscription, "owner": game.owner, "now": now, + "game_data": pretty_game_data, }) return context