Commit 2e0359f6 authored by Tim Heap's avatar Tim Heap
Browse files

Merge remote-tracking branch 'origin/master'

* origin/master:
  iSort all the things
  File input field is no longer required when editing
parents d2b86ae6 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
......
......@@ -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):
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment