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
8f7eabd3
Unverified
Commit
8f7eabd3
authored
Feb 05, 2021
by
seb-b
Committed by
GitHub
Feb 05, 2021
Browse files
Merge pull request #54 from neon-jungle/migrations_fix
Migrations fix
parents
837d5e96
c687d49f
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
README.rst
View file @
8f7eabd3
...
...
@@ -116,6 +116,7 @@ Same as Wagtail Images, a custom model can be used to replace the built in Video
# app.videos.models
from django.db import models
from modelcluster.fields import ParentalKey
from wagtailvideos.models import AbstractVideo, AbstractVideoTranscode
class AttributedVideo(AbstractVideo):
...
...
@@ -137,6 +138,13 @@ Same as Wagtail Images, a custom model can be used to replace the built in Video
unique_together = (
('video', 'media_format')
)
# Only needed if you are using the text tracks feature
class CustomTrackListing(AbstractTrackListing):
video = models.OneToOneField(AttributedVideo, related_name='track_listing', on_delete=models.CASCADE)
class CustomVideoTrack(AbstractVideoTrack):
listing = ParentalKey(CustomTrackListing, related_name='tracks', on_delete=models.CASCADE)
Video text tracks:
...
...
setup.py
View file @
8f7eabd3
...
...
@@ -10,7 +10,7 @@ from setuptools import find_packages, setup # noqa: E4
setup
(
name
=
'wagtailvideos'
,
version
=
'2.10.
0
'
,
version
=
'2.10.
1
'
,
description
=
"A wagtail module for uploading and displaying videos in various codecs."
,
long_description
=
readme
,
author
=
'Neon Jungle'
,
...
...
tests/app/migrations/0001_initial.py
View file @
8f7eabd3
This diff is collapsed.
Click to expand it.
tests/app/models.py
View file @
8f7eabd3
from
django.db
import
models
from
wagtail.core.models
import
Page
from
wagtail.core.fields
import
StreamField
from
modelcluster.fields
import
ParentalKey
from
wagtail.admin.edit_handlers
import
StreamFieldPanel
from
wagtail.core.fields
import
StreamField
from
wagtail.core.models
import
Page
from
wagtailvideos.edit_handlers
import
VideoChooserPanel
from
wagtailvideos.blocks
import
VideoChooserBlock
from
wagtailvideos.models
import
AbstractVideo
,
AbstractVideoTranscode
from
modelcluster.fields
import
ParentalKey
from
wagtailvideos.edit_handlers
import
VideoChooserPanel
from
wagtailvideos.models
import
(
AbstractTrackListing
,
AbstractVideo
,
AbstractVideoTrack
,
AbstractVideoTranscode
)
class
CustomVideoModel
(
AbstractVideo
):
...
...
@@ -31,6 +33,14 @@ class CustomVideoTranscode(AbstractVideoTranscode):
)
class
CustomTrackListing
(
AbstractTrackListing
):
video
=
models
.
OneToOneField
(
CustomVideoModel
,
related_name
=
'track_listing'
,
on_delete
=
models
.
CASCADE
)
class
CustomVideoTrack
(
AbstractVideoTrack
):
listing
=
ParentalKey
(
CustomTrackListing
,
related_name
=
'tracks'
,
on_delete
=
models
.
CASCADE
)
class
TestPage
(
Page
):
video_field
=
models
.
ForeignKey
(
CustomVideoModel
,
related_name
=
'+'
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
)
...
...
wagtailvideos/migrations/0011_
tracklisting_
videotrack.py
→
wagtailvideos/migrations/0011_video
_
track
s
.py
View file @
8f7eabd3
This diff is collapsed.
Click to expand it.
wagtailvideos/models.py
View file @
8f7eabd3
...
...
@@ -15,6 +15,7 @@ from django.core.exceptions import SuspiciousFileOperation
from
django.core.files.base
import
ContentFile
from
django.db
import
models
from
django.forms.utils
import
flatatt
from
django.apps
import
apps
from
django.urls
import
reverse
from
django.utils.safestring
import
mark_safe
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -179,6 +180,10 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
def
get_transcode_model
(
cls
):
return
cls
.
transcodes
.
rel
.
related_model
@
classmethod
def
get_track_listing_model
(
cls
):
return
cls
.
track_listing
.
related
.
related_model
def
video_tag
(
self
,
attrs
=
None
):
if
attrs
is
None
:
attrs
=
{}
...
...
@@ -222,7 +227,6 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
class
Meta
:
abstract
=
True
ordering
=
[
'-created_at'
]
class
Video
(
AbstractVideo
):
...
...
@@ -234,6 +238,9 @@ class Video(AbstractVideo):
'tags'
,
)
class
Meta
:
ordering
=
[
'-created_at'
]
class
TranscodingThread
(
threading
.
Thread
):
def
__init__
(
self
,
transcode
,
**
kwargs
):
...
...
@@ -319,17 +326,25 @@ class VideoTranscode(AbstractVideoTranscode):
)
class
TrackListing
(
ClusterableModel
):
video
=
models
.
OneToOneField
(
get_video_model_string
(),
on_delete
=
models
.
CASCADE
,
related_name
=
'track_listing'
)
class
AbstractTrackListing
(
ClusterableModel
):
def
__str__
(
self
):
return
self
.
video
.
title
@
classmethod
def
get_track_model
(
cls
):
return
cls
.
tracks
.
rel
.
related_model
class
VideoTrack
(
Orderable
):
listing
=
ParentalKey
(
TrackListing
,
related_name
=
'tracks'
,
on_delete
=
models
.
CASCADE
)
class
Meta
:
abstract
=
True
class
TrackListing
(
AbstractTrackListing
):
video
=
models
.
OneToOneField
(
Video
,
on_delete
=
models
.
CASCADE
,
related_name
=
'track_listing'
)
class
AbstractVideoTrack
(
Orderable
):
# TODO move to TextChoices once django < 3 is dropped
track_kinds
=
[
(
'subtitles'
,
'Subtitles'
),
...
...
@@ -375,3 +390,10 @@ class VideoTrack(Orderable):
folder_name
=
'video_tracks'
filename
=
self
.
file
.
field
.
storage
.
get_valid_name
(
filename
)
return
os
.
path
.
join
(
folder_name
,
filename
)
class
Meta
:
abstract
=
True
class
VideoTrack
(
AbstractVideoTrack
):
listing
=
ParentalKey
(
TrackListing
,
related_name
=
'tracks'
,
on_delete
=
models
.
CASCADE
)
wagtailvideos/signals.py
View file @
8f7eabd3
...
...
@@ -6,7 +6,6 @@ from django.db import transaction
from
django.db.models.signals
import
post_delete
,
post_save
from
wagtailvideos
import
ffmpeg
,
get_video_model
from
wagtailvideos.models
import
VideoTrack
@
contextmanager
...
...
@@ -68,6 +67,8 @@ def video_post_save(instance, **kwargs):
def
register_signal_handlers
():
Video
=
get_video_model
()
VideoTranscode
=
Video
.
get_transcode_model
()
TrackListing
=
Video
.
get_track_listing_model
()
VideoTrack
=
TrackListing
.
get_track_model
()
post_save
.
connect
(
video_post_save
,
sender
=
Video
)
post_delete
.
connect
(
post_delete_file_cleanup
,
sender
=
Video
)
...
...
wagtailvideos/views/videos.py
View file @
8f7eabd3
...
...
@@ -16,7 +16,6 @@ from wagtail.search.backends import get_search_backends
from
wagtailvideos
import
ffmpeg
,
get_video_model
,
is_modeladmin_installed
from
wagtailvideos.forms
import
VideoTranscodeAdminForm
,
get_video_form
from
wagtailvideos.permissions
import
permission_policy
from
wagtailvideos.models
import
TrackListing
if
LooseVersion
(
wagtail
.
__version__
)
>=
LooseVersion
(
'2.7'
):
from
wagtail.admin.auth
import
PermissionPolicyChecker
...
...
@@ -72,7 +71,6 @@ def index(request):
'videos'
:
page
,
'query_string'
:
query_string
,
'is_searching'
:
bool
(
query_string
),
'search_form'
:
form
,
'popular_tags'
:
popular_tags_for_model
(
Video
),
'current_collection'
:
current_collection
,
...
...
@@ -120,7 +118,7 @@ def edit(request, video_id):
messages
.
button
(
reverse
(
'wagtailvideos:delete'
,
args
=
(
video
.
id
,)),
_
(
'Delete'
))
])
if
is_modeladmin_installed
():
url_helper
=
AdminURLHelper
(
T
rack
L
isting
)
url_helper
=
AdminURLHelper
(
Video
.
get_t
rack
_l
isting
_model
()
)
if
hasattr
(
video
,
'track_listing'
):
action_url
=
url_helper
.
get_action_url
(
'edit'
,
instance_pk
=
video
.
track_listing
.
pk
)
else
:
...
...
wagtailvideos/wagtail_hooks.py
View file @
8f7eabd3
...
...
@@ -22,7 +22,7 @@ Video = get_video_model()
class
TracksAdmin
(
ModelAdmin
):
model
=
T
rack
L
isting
model
=
Video
.
get_t
rack
_l
isting
_model
()
menu_icon
=
'openquote'
menu_label
=
'Text tracks'
...
...
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