Commit e9db3e97 authored by Seb's avatar Seb
Browse files

Allow users to change the thumbnail. Use the thumbnail as the poster for the...

Allow users to change the thumbnail. Use the thumbnail as the poster for the video. Also fixed bug with transcoding form always passing no data
parent e00a361c
......@@ -2,12 +2,13 @@ from __future__ import absolute_import, print_function, unicode_literals
from django import forms
from django.forms.models import modelform_factory
from django.forms.widgets import FileInput
from django.utils.translation import ugettext as _
from enumchoicefield.forms import EnumField
from wagtail.wagtailadmin import widgets
from wagtail.wagtailadmin.forms import (BaseCollectionMemberForm,
collection_member_permission_formset_factory)
from enumchoicefield.forms import EnumField
from wagtailvideos.fields import WagtailVideoField
from wagtailvideos.models import MediaFormats, Video
from wagtailvideos.permissions import \
......@@ -48,6 +49,7 @@ def get_video_form(model):
widgets={
'tags': widgets.AdminTagWidget,
'file': forms.FileInput(),
'thumbnail': forms.FileInput(),
})
......@@ -55,7 +57,7 @@ class VideoTranscodeAdminForm(forms.Form):
media_format = EnumField(MediaFormats)
def __init__(self, video, data=None, **kwargs):
super(VideoTranscodeAdminForm, self).__init__(data=None, **kwargs)
super(VideoTranscodeAdminForm, self).__init__(data=data, **kwargs)
self.video = video
def save(self):
......
......@@ -204,7 +204,6 @@ class AbstractVideo(CollectionMember, TagSearchable):
transcode, created = self.transcodes.get_or_create(
media_format=media_format,
)
if transcode.processing is False:
transcode.processing = True
transcode.error_messages = ''
......@@ -222,6 +221,7 @@ class Video(AbstractVideo):
'title',
'file',
'collection',
'thumbnail',
'tags',
)
......
from __future__ import absolute_import, print_function, unicode_literals
import mimetypes
from django import template
from django.forms.widgets import flatatt
from django.template import resolve_variable
......@@ -28,7 +30,6 @@ def video(parser, token):
extra_attrs[param] = '' # attributes without values e.g. autoplay, controls
return VideoNode(video_expr, extra_attrs)
class VideoNode(template.Node):
def __init__(self, video, attrs={}):
self.video = template.Variable(video)
......@@ -40,8 +41,11 @@ class VideoNode(template.Node):
if not video:
raise template.TemplateSyntaxError("video tag requires a Video object as the first parameter")
sources = ["<source src='{0}' type='video/{1}'>"
.format(video.url, video.file_ext)] # TODO get mimetype properly (extension is not always reliable)
self.attrs['poster'] = video.thumbnail.url
mime = mimetypes.MimeTypes()
sources = ["<source src='{0}' type='{1}'>"
.format(video.url, mime.guess_type(video.url)[0])]
transcodes = video.transcodes.exclude(processing=True).filter(error_message__exact='')
for transcode in transcodes:
......
......@@ -126,7 +126,6 @@ def edit(request, video_id):
def create_transcode(request, video_id):
if request.method != 'POST':
return HttpResponseNotAllowed(['POST'])
video = get_object_or_404(Video, id=video_id)
transcode_form = VideoTranscodeAdminForm(data=request.POST, video=video)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment