Add YouTube playlist support in game detail views and create custom template tag
This commit is contained in:
parent
08e4d6e75b
commit
3042382ae4
5 changed files with 20 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load form %}
|
{% load form youtube %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
{% if group.owner == user %}
|
{% if group.owner == user %}
|
||||||
|
@ -39,6 +39,9 @@
|
||||||
<thead>
|
<thead>
|
||||||
{% if group.owner == user %}<th></th>{% endif %}
|
{% if group.owner == user %}<th></th>{% endif %}
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
|
<th>
|
||||||
|
<i class="ri-youtube-fill"></i> Playlists
|
||||||
|
</th>
|
||||||
<th>Joueurs</th>
|
<th>Joueurs</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -52,6 +55,11 @@
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if game.playlist %}
|
||||||
|
<a href="{% yt_playlist game %}"><i class="ri-youtube-fill"></i> Playlist</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>{{ game.players.all|join:", " }}</td>
|
<td>{{ game.players.all|join:", " }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load youtube %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
<i class="ri-play-circle-fill"></i> {{ musikgame.date }}
|
<i class="ri-play-circle-fill"></i> {{ musikgame.date }}
|
||||||
|
@ -6,7 +7,7 @@
|
||||||
{% if musikgame.playlist or musikgame.playlist_loading %}
|
{% if musikgame.playlist or musikgame.playlist_loading %}
|
||||||
<p>
|
<p>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
href="https://youtube.com/watch?v={{ musikgame.musicgameorder_set.first.music_video.yt_id }}&list={{ musikgame.playlist }}"
|
href="{% yt_playlist musikgame %}"
|
||||||
role="button"
|
role="button"
|
||||||
{% if musikgame.playlist_loading %}aria-busy="true"{% endif %}><i class="ri-youtube-fill"></i> Playlist</a>
|
{% if musikgame.playlist_loading %}aria-busy="true"{% endif %}><i class="ri-youtube-fill"></i> Playlist</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
1
game/templates/tags/youtube/playlist.html
Normal file
1
game/templates/tags/youtube/playlist.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<a href="{{ url }}">{{ text }}</a>
|
0
game/templatetags/__init__.py
Normal file
0
game/templatetags/__init__.py
Normal file
8
game/templatetags/youtube.py
Normal file
8
game/templatetags/youtube.py
Normal file
|
@ -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}"
|
Loading…
Add table
Add a link
Reference in a new issue