Add JSON serialization for game data in game detail view
This commit is contained in:
parent
265f8ed671
commit
4b1329befb
2 changed files with 16 additions and 0 deletions
|
|
@ -84,4 +84,5 @@
|
||||||
{% if not active_campaigns and not upcoming_campaigns and not expired_campaigns %}
|
{% if not active_campaigns and not upcoming_campaigns and not expired_campaigns %}
|
||||||
No campaigns found for this game.
|
No campaigns found for this game.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<pre><code>{{ game_data }}</code></pre>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -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]
|
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({
|
context.update({
|
||||||
"active_campaigns": active_campaigns,
|
"active_campaigns": active_campaigns,
|
||||||
"upcoming_campaigns": upcoming_campaigns,
|
"upcoming_campaigns": upcoming_campaigns,
|
||||||
|
|
@ -298,6 +312,7 @@ class GameDetailView(DetailView):
|
||||||
"subscription": subscription,
|
"subscription": subscription,
|
||||||
"owner": game.owner,
|
"owner": game.owner,
|
||||||
"now": now,
|
"now": now,
|
||||||
|
"game_data": pretty_game_data,
|
||||||
})
|
})
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue