From 3042382ae4dcd0e3b08548e5935a9b94ac563d87 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Sat, 14 Jun 2025 12:53:46 +0200 Subject: [PATCH] Add YouTube playlist support in game detail views and create custom template tag --- game/templates/game/group_detail.html | 10 +++++++++- game/templates/game/musikgame_detail.html | 3 ++- game/templates/tags/youtube/playlist.html | 1 + game/templatetags/__init__.py | 0 game/templatetags/youtube.py | 8 ++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 game/templates/tags/youtube/playlist.html create mode 100644 game/templatetags/__init__.py create mode 100644 game/templatetags/youtube.py diff --git a/game/templates/game/group_detail.html b/game/templates/game/group_detail.html index 8fc9186..e3b5f56 100644 --- a/game/templates/game/group_detail.html +++ b/game/templates/game/group_detail.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load form %} +{% load form youtube %} {% block content %}

{% if group.owner == user %} @@ -39,6 +39,9 @@ {% if group.owner == user %}{% endif %} Date + + Playlists + Joueurs @@ -52,6 +55,11 @@ {{ game.date }} + + {% if game.playlist %} + Playlist + {% endif %} + {{ game.players.all|join:", " }} {% endfor %} diff --git a/game/templates/game/musikgame_detail.html b/game/templates/game/musikgame_detail.html index 7d16d64..444c7f1 100644 --- a/game/templates/game/musikgame_detail.html +++ b/game/templates/game/musikgame_detail.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load youtube %} {% block content %}

{{ musikgame.date }} @@ -6,7 +7,7 @@ {% if musikgame.playlist or musikgame.playlist_loading %}

Playlist

diff --git a/game/templates/tags/youtube/playlist.html b/game/templates/tags/youtube/playlist.html new file mode 100644 index 0000000..3270d81 --- /dev/null +++ b/game/templates/tags/youtube/playlist.html @@ -0,0 +1 @@ +{{ text }} diff --git a/game/templatetags/__init__.py b/game/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/game/templatetags/youtube.py b/game/templatetags/youtube.py new file mode 100644 index 0000000..6fc1ac1 --- /dev/null +++ b/game/templatetags/youtube.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.simple_tag +def yt_playlist(game): + return f"https://youtube.com/watch?v={game.musicgameorder_set.first().music_video.yt_id}&list={game.playlist}"