From 768def6630081fce68bdcb014b18025102ecc38d Mon Sep 17 00:00:00 2001 From: Bastiaan Welmers Date: Tue, 5 Apr 2022 17:59:23 +0200 Subject: [PATCH] Move variable mapping details from template to view function --- videodinges/templates/video.html.j2 | 2 +- videodinges/views.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/videodinges/templates/video.html.j2 b/videodinges/templates/video.html.j2 index 4e8aa7d..57f16c4 100644 --- a/videodinges/templates/video.html.j2 +++ b/videodinges/templates/video.html.j2 @@ -13,7 +13,7 @@ {% endfor %} {% for track in tracks %} - + {% endfor %} You need a browser that understands HTML5 video and supports {% for i in used_codecs %}{{ i }}{% if not loop.last %} or {% endif %}{% endfor %} codecs.
diff --git a/videodinges/views.py b/videodinges/views.py index 2d113d7..0e2a938 100644 --- a/videodinges/views.py +++ b/videodinges/views.py @@ -51,7 +51,15 @@ def video(request: HttpRequest, slug: str) -> HttpResponse: template_data['qualities'] = qualities.keys() - template_data['tracks'] = video.tracks.all() + template_data['tracks'] = [ + { + 'default': track.default, + 'src': track.upload.file.url, + 'srclang': track.lang, + 'kind': track.kind, + 'label': track.label or track.lang, + } for track in video.tracks.all() + ] return render(request, 'video.html.j2', template_data, using='jinja2')