Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Wagtail Videos
Commits
5a809ce4
Commit
5a809ce4
authored
Aug 01, 2016
by
seb-b
Committed by
GitHub
Aug 01, 2016
Browse files
Merge pull request #2 from takeflight/poster
Poster attribute + bug fix
parents
e00a361c
e9db3e97
Changes
4
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/forms.py
View file @
5a809ce4
...
...
@@ -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
):
...
...
wagtailvideos/models.py
View file @
5a809ce4
...
...
@@ -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'
,
)
...
...
wagtailvideos/templatetags/wagtailvideos_tags.py
View file @
5a809ce4
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
:
...
...
wagtailvideos/views/videos.py
View file @
5a809ce4
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment