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
69f5b131
Commit
69f5b131
authored
Jul 29, 2016
by
Seb
Browse files
Created formatted_duration method for nice formatting of video duration
parent
d2d380ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/models.py
View file @
69f5b131
...
@@ -19,6 +19,7 @@ from django.db.models.signals import post_save, pre_delete
...
@@ -19,6 +19,7 @@ from django.db.models.signals import post_save, pre_delete
from
django.dispatch.dispatcher
import
receiver
from
django.dispatch.dispatcher
import
receiver
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
enumchoicefield
import
ChoiceEnum
,
EnumChoiceField
from
taggit.managers
import
TaggableManager
from
taggit.managers
import
TaggableManager
from
unidecode
import
unidecode
from
unidecode
import
unidecode
from
wagtail.wagtailadmin.taggable
import
TagSearchable
from
wagtail.wagtailadmin.taggable
import
TagSearchable
...
@@ -27,8 +28,6 @@ from wagtail.wagtailcore.models import CollectionMember
...
@@ -27,8 +28,6 @@ from wagtail.wagtailcore.models import CollectionMember
from
wagtail.wagtailsearch
import
index
from
wagtail.wagtailsearch
import
index
from
wagtail.wagtailsearch.queryset
import
SearchableQuerySetMixin
from
wagtail.wagtailsearch.queryset
import
SearchableQuerySetMixin
from
enumchoicefield
import
ChoiceEnum
,
EnumChoiceField
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -66,6 +65,10 @@ class AbstractVideo(CollectionMember, TagSearchable):
...
@@ -66,6 +65,10 @@ class AbstractVideo(CollectionMember, TagSearchable):
objects
=
VideoQuerySet
.
as_manager
()
objects
=
VideoQuerySet
.
as_manager
()
search_fields
=
list
(
TagSearchable
.
search_fields
)
+
list
(
CollectionMember
.
search_fields
)
+
[
index
.
FilterField
(
'uploaded_by_user'
),
]
def
is_stored_locally
(
self
):
def
is_stored_locally
(
self
):
"""
"""
Returns True if the image is hosted on the local filesystem
Returns True if the image is hosted on the local filesystem
...
@@ -106,9 +109,13 @@ class AbstractVideo(CollectionMember, TagSearchable):
...
@@ -106,9 +109,13 @@ class AbstractVideo(CollectionMember, TagSearchable):
def
usage_url
(
self
):
def
usage_url
(
self
):
return
reverse
(
'wagtailvideos:video_usage'
,
args
=
(
self
.
id
,))
return
reverse
(
'wagtailvideos:video_usage'
,
args
=
(
self
.
id
,))
search_fields
=
list
(
TagSearchable
.
search_fields
)
+
list
(
CollectionMember
.
search_fields
)
+
[
@
property
index
.
FilterField
(
'uploaded_by_user'
),
def
formatted_duration
(
self
):
]
if
(
self
.
duration
):
hours
,
remainder
=
divmod
(
self
.
duration
.
seconds
,
3600
)
minutes
,
seconds
=
divmod
(
remainder
,
60
)
return
"%d:%02d:%02d"
%
(
hours
,
minutes
,
seconds
)
return
''
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
...
@@ -119,6 +126,7 @@ class AbstractVideo(CollectionMember, TagSearchable):
...
@@ -119,6 +126,7 @@ class AbstractVideo(CollectionMember, TagSearchable):
file_path
=
self
.
file
.
path
file_path
=
self
.
file
.
path
try
:
try
:
# FIXME prints out extra stuff on travis, pip stderr to dev/null
show_format
=
subprocess
.
check_output
([
'ffprobe'
,
file_path
,
'-show_format'
,
'-v'
,
'quiet'
])
show_format
=
subprocess
.
check_output
([
'ffprobe'
,
file_path
,
'-show_format'
,
'-v'
,
'quiet'
])
show_format
=
show_format
.
decode
(
"utf-8"
)
show_format
=
show_format
.
decode
(
"utf-8"
)
# show_format comes out in key=value pairs seperated by newlines
# show_format comes out in key=value pairs seperated by newlines
...
...
wagtailvideos/templates/wagtailvideos/videos/edit.html
View file @
69f5b131
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
<dt>
{% trans "Filesize" %}
</dt>
<dt>
{% trans "Filesize" %}
</dt>
<dd>
{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}
</dd>
<dd>
{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}
</dd>
<dt>
{% trans "Duration" %}
</dt>
<dt>
{% trans "Duration" %}
</dt>
<dd>
{{ video.duration }}
</dd>
<dd>
{{ video.
formatted_
duration }}
</dd>
</dl>
</dl>
</div>
</div>
</div>
</div>
...
...
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