{% 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" /> {% 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" /> {% trans "Download" %}</a>
</div>
{% endif %}
{% endif %}
{% 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>
</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 %}
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:
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)