From: Guillaume Pellerin Date: Fri, 17 Aug 2018 00:30:09 +0000 (+0200) Subject: Fix media url, add 404 X-Git-Tag: 1.3.1~1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b4c9f9737344cb5e4c1f451d3558e9ed296bf645;p=teleforma.git Fix media url, add 404 --- diff --git a/teleforma/templates/teleforma/course_media.html b/teleforma/templates/teleforma/course_media.html index 5b2d326b..336a3291 100644 --- a/teleforma/templates/teleforma/course_media.html +++ b/teleforma/templates/teleforma/course_media.html @@ -61,7 +61,7 @@ $(document).ready(function(){ {% if media.item.file and media.is_published or user.is_superuser or user.is_staff %} {% if not "video" in media.mime_type or perms.telemeta.can_play_all_items or request.user_agent.os.family == 'iOS' %}
-  {% trans "Download" %} +  {% trans "Download" %}
{% endif %} {% endif %} @@ -97,7 +97,7 @@ $(document).ready(function(){ {% if "video" in media.mime_type %}
@@ -121,7 +121,7 @@ $(document).ready(function(){
{% endif %} diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 4378e910..6db396c9 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -241,7 +241,7 @@ def serve_media(media_path, content_type="", buffering=True, streaming=False): if not content_type: content_type = mimetypes.guess_type(media_path)[0] - if settings.DEBUG: + if not settings.DEBUG: return nginx_media_accel(media_path, content_type=content_type, buffering=buffering, streaming=streaming) else: @@ -473,9 +473,9 @@ class MediaView(CourseAccessMixin, DetailView): media = Media.objects.get(id=pk) if get_access(media, courses): media_path = media.item.file.path - return serve_media(media_path, streaming=streaming) + return serve_media(media_path, content_type=media.mime_type, streaming=streaming) else: - return redirect('teleforma-media-detail', period_id, pk) + raise Http404("You don't have access to this media.") def download(self, request, period_id, pk): return self.streaming(request, period_id, pk, streaming=False)