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
fc0f8eed
Commit
fc0f8eed
authored
Jun 29, 2016
by
Seb
Browse files
Fix for wagtail 1.5, can now upload videos
parent
472b4bd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/forms.py
View file @
fc0f8eed
...
...
@@ -2,12 +2,18 @@ from django import forms
from
django.forms.models
import
modelform_factory
from
django.utils.translation
import
ugettext
as
_
from
wagtail.wagtailadmin
import
widgets
from
wagtail.wagtailadmin.forms
import
\
collection_member_permission_formset_factory
from
wagtail.wagtailadmin.forms
import
(
BaseCollectionMemberForm
,
collection_member_permission_formset_factory
)
from
wagtailvideos.fields
import
WagtailVideoField
from
wagtailvideos.formats
import
get_video_formats
from
wagtailvideos.models
import
Video
from
wagtailvideos.permissions
import
\
permission_policy
as
video_permission_policy
class
BaseVideoForm
(
BaseCollectionMemberForm
):
permission_policy
=
video_permission_policy
# Callback to allow us to override the default form field for the image file field
def
formfield_for_dbfield
(
db_field
,
**
kwargs
):
...
...
@@ -26,10 +32,12 @@ def get_video_form(model):
# cause dubious results when multiple collections exist (e.g adding the
# document to the root collection where the user may not have permission) -
# and when only one collection exists, it will get hidden anyway.
print
(
'collection not found'
)
fields
=
list
(
fields
)
+
[
'collection'
]
return
modelform_factory
(
model
,
form
=
BaseVideoForm
,
fields
=
fields
,
formfield_callback
=
formfield_for_dbfield
,
# set the 'file' widget to a FileInput rather than the default ClearableFileInput
...
...
@@ -38,10 +46,6 @@ def get_video_form(model):
widgets
=
{
'tags'
:
widgets
.
AdminTagWidget
,
'file'
:
forms
.
FileInput
(),
'focal_point_x'
:
forms
.
HiddenInput
(
attrs
=
{
'class'
:
'focal_point_x'
}),
'focal_point_y'
:
forms
.
HiddenInput
(
attrs
=
{
'class'
:
'focal_point_y'
}),
'focal_point_width'
:
forms
.
HiddenInput
(
attrs
=
{
'class'
:
'focal_point_width'
}),
'focal_point_height'
:
forms
.
HiddenInput
(
attrs
=
{
'class'
:
'focal_point_height'
}),
})
...
...
wagtailvideos/widgets.py
View file @
fc0f8eed
...
...
@@ -5,6 +5,7 @@ import json
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
ugettext_lazy
as
_
from
wagtail.wagtailadmin.widgets
import
AdminChooser
from
wagtailvideos.models
import
get_video_model
...
...
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