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
8e607cd5
Commit
8e607cd5
authored
Jan 30, 2017
by
Tim Heap
Committed by
GitHub
Jan 30, 2017
Browse files
Merge pull request #18 from takeflight/file-field
Make file input field not required when editing
parents
e297936f
8d48fee7
Changes
6
Hide whitespace changes
Inline
Side-by-side
tests/test_admin_views.py
View file @
8e607cd5
...
...
@@ -228,6 +228,7 @@ class TestVideoEditView(TestCase, WagtailTestUtils):
# Check that the video was edited
video
=
Video
.
objects
.
get
(
id
=
self
.
video
.
id
)
self
.
assertEqual
(
video
.
title
,
"Edited"
)
self
.
assertEqual
(
self
.
video
.
file
,
video
.
file
)
def
test_edit_with_new_video_file
(
self
):
# Change the file size of the video
...
...
wagtailvideos/forms.py
View file @
8e607cd5
...
...
@@ -17,6 +17,14 @@ from wagtailvideos.permissions import \
class
BaseVideoForm
(
BaseCollectionMemberForm
):
permission_policy
=
video_permission_policy
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
BaseVideoForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
# A file is only required if there is not already a file, such as when
# editing an existing video. The file field is not used on the
# multiple-upload forms, so may not be present
if
'file'
in
self
.
fields
:
self
.
fields
[
'file'
].
required
=
'file'
not
in
self
.
initial
or
not
self
.
initial
[
'file'
]
# Callback to allow us to override the default form field for the image file field
def
formfield_for_dbfield
(
db_field
,
**
kwargs
):
...
...
wagtailvideos/models.py
View file @
8e607cd5
...
...
@@ -11,7 +11,6 @@ import subprocess
import
tempfile
import
threading
import
django
from
django.conf
import
settings
from
django.core.files.base
import
ContentFile
from
django.core.urlresolvers
import
reverse
...
...
wagtailvideos/views/chooser.py
View file @
8e607cd5
...
...
@@ -11,7 +11,6 @@ from wagtail.wagtailadmin.utils import (
PermissionPolicyChecker
,
popular_tags_for_model
)
from
wagtail.wagtailcore.models
import
Collection
from
wagtail.wagtailsearch
import
index
as
search_index
from
wagtail.wagtailsearch.backends
import
get_search_backends
from
wagtailvideos.forms
import
get_video_form
from
wagtailvideos.models
import
Video
...
...
wagtailvideos/views/videos.py
View file @
8e607cd5
...
...
@@ -76,7 +76,6 @@ def index(request):
@
permission_checker
.
require
(
'change'
)
def
edit
(
request
,
video_id
):
VideoForm
=
get_video_form
(
Video
)
video
=
get_object_or_404
(
Video
,
id
=
video_id
)
if
request
.
POST
:
...
...
wagtailvideos/wagtail_hooks.py
View file @
8e607cd5
...
...
@@ -8,10 +8,9 @@ from django.utils.translation import ugettext_lazy as _
from
wagtail.wagtailadmin.menu
import
MenuItem
from
wagtail.wagtailcore
import
hooks
from
wagtailvideos
import
urls
from
wagtailvideos.forms
import
GroupVideoPermissionFormSet
from
.
import
urls
@
hooks
.
register
(
'register_admin_urls'
)
def
register_admin_urls
():
...
...
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