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
3e0677e0
Commit
3e0677e0
authored
Sep 28, 2016
by
Liam Brenner
Committed by
GitHub
Sep 28, 2016
Browse files
Merge pull request #10 from takeflight/cleanup
Cleanup, enforce isort and flake8
parents
d5be1142
0dc15f0c
Changes
11
Show whitespace changes
Inline
Side-by-side
.travis.yml
View file @
3e0677e0
language
:
python
cache
:
pip
# Matrix of build options
python
:
-
'
2.7'
-
'
3.4'
-
'
3.5'
env
:
global
:
-
DJANGO_SETTINGS_MODULE="tests.app.settings"
-
TOX_ENV=
matrix
:
-
DJANGO='18' WAGTAIL='14'
-
DJANGO='19' WAGTAIL='14'
-
DJANGO='18' WAGTAIL='15'
-
DJANGO='19' WAGTAIL='15'
-
DJANGO='19' WAGTAIL='16'
-
DJANGO='110' WAGTAIL='16'
-
TOX_ENV=flake8,isort
matrix
:
-
env
:
DJANGO='18' WAGTAIL='14'
python
:
2.7
-
env
:
DJANGO='18' WAGTAIL='14'
python
:
3.4
-
env
:
DJANGO='18' WAGTAIL='14'
python
:
3.5
-
env
:
DJANGO='19' WAGTAIL='14'
python
:
2.7
-
env
:
DJANGO='19' WAGTAIL='14'
python
:
3.4
-
env
:
DJANGO='19' WAGTAIL='14'
python
:
3.5
-
env
:
DJANGO='18' WAGTAIL='15'
python
:
2.7
-
env
:
DJANGO='18' WAGTAIL='15'
python
:
3.4
-
env
:
DJANGO='18' WAGTAIL='15'
python
:
3.5
-
env
:
DJANGO='19' WAGTAIL='15'
python
:
2.7
-
env
:
DJANGO='19' WAGTAIL='15'
python
:
3.4
-
env
:
DJANGO='19' WAGTAIL='15'
python
:
3.5
-
env
:
DJANGO='19' WAGTAIL='16'
python
:
2.7
-
env
:
DJANGO='19' WAGTAIL='16'
python
:
3.4
-
env
:
DJANGO='19' WAGTAIL='16'
python
:
3.5
-
env
:
DJANGO='110' WAGTAIL='16'
python
:
2.7
-
env
:
DJANGO='110' WAGTAIL='16'
python
:
3.4
-
env
:
DJANGO='110' WAGTAIL='16'
python
:
3.5
-
env
:
TOX_ENV='flake8,isort'
python
:
3.5
before_install
:
# - sudo add-apt-repository ppa:mc3man/trusty-media -y // Inlcudes all multimedia options but 404s currently :(
...
...
setup.cfg
View file @
3e0677e0
[metadata]
description-file = README.rst
[bdist_wheel]
universal = 1
[isort]
skip_glob = */migrations/*
line_length = 79
multi_line_output = 4
[pep8]
max-line-length = 100
[flake8]
max-line-length = 100
ignore = E501
exclude = migrations
tests/test_template_tag.py
View file @
3e0677e0
...
...
@@ -16,7 +16,7 @@ class TestVideoTag(TestCase):
def
render_video_tag
(
self
,
video
,
attrs
=
''
):
temp
=
Template
(
'{% load wagtailvideos_tags %}{% video video_obj '
+
attrs
+
' %}'
)
context
=
Context
({
'video_obj'
:
video
})
context
=
Context
({
'video_obj'
:
video
})
return
temp
.
render
(
context
)
def
test_video_tag
(
self
):
...
...
tox.ini
View file @
3e0677e0
...
...
@@ -8,14 +8,18 @@ envlist =
py{27,34,35}-dj{18,19}-wt15
# Current version
py{27,34,35}-dj{19,110}-wt16
# Enforce good style
flake8,isort
[base]
deps
=
mock
[testenv]
commands
=
python runtests.py {posargs}
pip_pre
=
True
deps
=
mock
{
[base]
deps}
dj18:
Django~=1.8.0
dj19:
Django~=1.9.0
dj110:
Django~=1.10.0
...
...
@@ -23,3 +27,16 @@ deps =
wt14:
wagtail~=1.4.0
wt15:
wagtail~=1.5.0
wt16:
wagtail~=1.6.0
[testenv:flake8]
deps
=
flake8
basepython
=
python3.5
commands
=
flake8 wagtailvideos/ tests/
[testenv:isort]
usedevelop
=
True
deps
=
{
[base]
deps}
isort
=
=4.2.2
basepython
=
python3.5
commands
=
isort --recursive --diff --check-only wagtailvideos/ tests/
wagtailvideos/fields.py
View file @
3e0677e0
from
__future__
import
absolute_import
,
print_function
,
unicode_literals
import
os
from
django.conf
import
settings
from
django.core.exceptions
import
ValidationError
from
django.forms.fields
import
FileField
...
...
wagtailvideos/forms.py
View file @
3e0677e0
...
...
@@ -2,12 +2,11 @@ from __future__ import absolute_import, print_function, unicode_literals
from
django
import
forms
from
django.forms.models
import
modelform_factory
from
django.forms.widgets
import
FileInput
from
django.utils.translation
import
ugettext
as
_
from
enumchoicefield.forms
import
EnumField
from
wagtail.wagtailadmin
import
widgets
from
wagtail.wagtailadmin.forms
import
(
BaseCollectionMemberForm
,
collection_member_permission_formset_factory
)
from
wagtail.wagtailadmin.forms
import
(
BaseCollectionMemberForm
,
collection_member_permission_formset_factory
)
from
wagtailvideos.fields
import
WagtailVideoField
from
wagtailvideos.models
import
MediaFormats
,
Video
,
VideoQuality
...
...
@@ -18,6 +17,7 @@ from wagtailvideos.permissions import \
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
):
# Check if this is the file field
...
...
wagtailvideos/models.py
View file @
3e0677e0
...
...
@@ -24,7 +24,6 @@ from django.utils.text import mark_safe
from
django.utils.translation
import
ugettext_lazy
as
_
from
enumchoicefield
import
ChoiceEnum
,
EnumChoiceField
from
taggit.managers
import
TaggableManager
from
unidecode
import
unidecode
from
wagtail.wagtailadmin.taggable
import
TagSearchable
from
wagtail.wagtailadmin.utils
import
get_object_usage
from
wagtail.wagtailcore.models
import
CollectionMember
...
...
@@ -67,6 +66,7 @@ class MediaFormats(ChoiceEnum):
VideoQuality
.
highest
:
'9'
}[
quality
]
class
VideoQuerySet
(
SearchableQuerySetMixin
,
models
.
QuerySet
):
pass
...
...
wagtailvideos/templatetags/wagtailvideos_tags.py
View file @
3e0677e0
...
...
@@ -5,7 +5,6 @@ import mimetypes
from
django
import
template
from
django.forms.widgets
import
flatatt
from
django.utils.text
import
mark_safe
from
wagtailvideos.models
import
MediaFormats
,
Video
register
=
template
.
Library
()
# {% video self.intro_video extra_att extra_att %}
...
...
@@ -28,6 +27,7 @@ def video(parser, token):
extra_attrs
[
param
]
=
''
# attributes without values e.g. autoplay, controls
return
VideoNode
(
video_expr
,
extra_attrs
)
class
VideoNode
(
template
.
Node
):
def
__init__
(
self
,
video
,
attrs
=
{}):
self
.
video
=
template
.
Variable
(
video
)
...
...
wagtailvideos/views/multiple.py
View file @
3e0677e0
...
...
@@ -41,7 +41,6 @@ def add(request):
# no need to show a collections chooser
collections_to_choose
=
None
if
request
.
method
==
'POST'
:
if
not
request
.
is_ajax
():
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
...
...
wagtailvideos/views/videos.py
View file @
3e0677e0
...
...
@@ -2,8 +2,8 @@ from __future__ import absolute_import, print_function, unicode_literals
import
os
from
django.core.urlresolvers
import
NoReverseMatch
,
reverse
from
django.http
import
HttpResponseNotAllowed
,
JsonResponse
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpResponseNotAllowed
from
django.shortcuts
import
get_object_or_404
,
redirect
,
render
from
django.utils.translation
import
ugettext
as
_
from
django.views.decorators.vary
import
vary_on_headers
...
...
@@ -11,7 +11,7 @@ from wagtail.utils.pagination import paginate
from
wagtail.wagtailadmin
import
messages
from
wagtail.wagtailadmin.forms
import
SearchForm
from
wagtail.wagtailadmin.utils
import
PermissionPolicyChecker
from
wagtail.wagtailcore.models
import
Collection
,
Site
from
wagtail.wagtailcore.models
import
Collection
from
wagtail.wagtailsearch.backends
import
get_search_backends
from
wagtailvideos.forms
import
VideoTranscodeAdminForm
,
get_video_form
...
...
@@ -21,6 +21,7 @@ from wagtailvideos.utils import ffmpeg_installed
permission_checker
=
PermissionPolicyChecker
(
permission_policy
)
@
permission_checker
.
require_any
(
'add'
,
'change'
,
'delete'
)
@
vary_on_headers
(
'X-Requested-With'
)
def
index
(
request
):
...
...
@@ -125,6 +126,7 @@ def edit(request, video_id):
'user_can_delete'
:
permission_policy
.
user_has_permission_for_instance
(
request
.
user
,
'delete'
,
video
)
})
def
create_transcode
(
request
,
video_id
):
if
request
.
method
!=
'POST'
:
return
HttpResponseNotAllowed
([
'POST'
])
...
...
wagtailvideos/wagtail_hooks.py
View file @
3e0677e0
...
...
@@ -38,10 +38,12 @@ def editor_js():
urlresolvers
.
reverse
(
'wagtailvideos:chooser'
)
)
@
hooks
.
register
(
'register_group_permission_panel'
)
def
register_video_permissions_panel
():
return
GroupVideoPermissionFormSet
@
hooks
.
register
(
'register_admin_menu_item'
)
def
register_images_menu_item
():
return
MenuItem
(
...
...
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