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" %}
|
||||
{% load form %}
|
||||
{% load form youtube %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
{% if group.owner == user %}
|
||||
|
@ -39,6 +39,9 @@
|
|||
<thead>
|
||||
{% if group.owner == user %}<th></th>{% endif %}
|
||||
<th>Date</th>
|
||||
<th>
|
||||
<i class="ri-youtube-fill"></i> Playlists
|
||||
</th>
|
||||
<th>Joueurs</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -52,6 +55,11 @@
|
|||
<td>
|
||||
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
||||
</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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load youtube %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
<i class="ri-play-circle-fill"></i> {{ musikgame.date }}
|
||||
|
@ -6,7 +7,7 @@
|
|||
{% if musikgame.playlist or musikgame.playlist_loading %}
|
||||
<p>
|
||||
<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"
|
||||
{% if musikgame.playlist_loading %}aria-busy="true"{% endif %}><i class="ri-youtube-fill"></i> Playlist</a>
|
||||
</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