]> git.parisson.com Git - teleforma.git/commitdiff
Fix media url, add 404
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 17 Aug 2018 00:30:09 +0000 (02:30 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 17 Aug 2018 00:30:09 +0000 (02:30 +0200)
teleforma/templates/teleforma/course_media.html
teleforma/views/core.py

index 5b2d326b684e86d9236a0ca5ba383e6a904fa788..336a32912f30e3fe2583c5b3a54359c43dec121c 100644 (file)
@@ -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' %}
   <div class="module_action">
-   <a href="{% url 'teleforma-media-download' period.id media.pk %}" class="component_icon button" id="action_red"><img src="/static/teleforma/images/download_media.png" alt="" style="vertical-align:middle" />&nbsp;{% trans "Download" %}</a>
+   <a href="{% url teleforma-media-download period.id media.id %}" class="component_icon button" id="action_red"><img src="/static/teleforma/images/download_media.png" alt="" style="vertical-align:middle" />&nbsp;{% trans "Download" %}</a>
   </div>
  {% endif %}
 {% endif %}
@@ -97,7 +97,7 @@ $(document).ready(function(){
 {% if "video" in media.mime_type %}
 <div class="video">
     <video id="my_video_1" class="video-js vjs-default-skin" width="864" height="480" controls preload="auto" data-setup='{}' {% if media.item.related.all %}{% for related in media.item.related.all %}{% if related.title == "preview" %}{% thumbnail related.file "640" as im %}poster="{{ im.url }}"{% endthumbnail %}{% endif %}{% endfor %}{% endif %}>
-        <source src="{% url 'teleforma-media-streaming' period.id media.pk %}" type="{{ media.mime_type }}" />
+        <source src="{% url teleforma-media-streaming period.id media.id %}" type="{{ media.mime_type }}" />
     </video>
 </div>
 
@@ -121,7 +121,7 @@ $(document).ready(function(){
 </div>
 <div class="audio">
     <audio controls preload="auto">
-        <source src="{% url 'teleforma-media-streaming' period.id media.pk %}" type="{{ media.mime_type }}" />
+        <source src="{% url teleforma-media-streaming period.id media.id %}" type="{{ media.mime_type }}" />
     </audio>
 </div>
 {% endif %}
index 4378e91002e19c7d15b8e9b6977ac9448095cd3e..6db396c982f51aac83d5ae384310c0815ff07126 100644 (file)
@@ -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)