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
2fe3bfdf
Unverified
Commit
2fe3bfdf
authored
May 16, 2022
by
Seb Brown
Committed by
GitHub
May 16, 2022
Browse files
Merge pull request #87 from jkevingutierrez/feature/django-4.0
Start preparing things for Django4.0
parents
ff0e033b
6219acf7
Changes
10
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
2fe3bfdf
...
@@ -19,7 +19,7 @@ setup(
...
@@ -19,7 +19,7 @@ setup(
install_requires
=
[
install_requires
=
[
'wagtail>=2.5'
,
'wagtail>=2.5'
,
'Django>=
1.11
'
,
'Django>=
2.0
'
,
'django-enumchoicefield>=1.1.0'
,
'django-enumchoicefield>=1.1.0'
,
'bcp47==0.0.4'
,
'bcp47==0.0.4'
,
],
],
...
...
tests/storage.py
View file @
2fe3bfdf
...
@@ -10,7 +10,7 @@ from django.core.files.storage import FileSystemStorage
...
@@ -10,7 +10,7 @@ from django.core.files.storage import FileSystemStorage
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.utils._os
import
safe_join
from
django.utils._os
import
safe_join
from
django.utils.deconstruct
import
deconstructible
from
django.utils.deconstruct
import
deconstructible
from
django.utils.encoding
import
filepath_to_uri
,
force_
text
from
django.utils.encoding
import
filepath_to_uri
,
force_
str
@
deconstructible
@
deconstructible
...
@@ -101,7 +101,7 @@ class RemoteStorage(FileSystemStorage):
...
@@ -101,7 +101,7 @@ class RemoteStorage(FileSystemStorage):
os
.
chmod
(
full_path
,
self
.
file_permissions_mode
)
os
.
chmod
(
full_path
,
self
.
file_permissions_mode
)
# Store filenames with forward slashes, even on Windows.
# Store filenames with forward slashes, even on Windows.
return
force_
text
(
name
.
replace
(
'
\\
'
,
'/'
))
return
force_
str
(
name
.
replace
(
'
\\
'
,
'/'
))
def
delete
(
self
,
name
):
def
delete
(
self
,
name
):
assert
name
,
"The name argument is not allowed to be empty."
assert
name
,
"The name argument is not allowed to be empty."
...
...
wagtailvideos/fields.py
View file @
2fe3bfdf
...
@@ -2,7 +2,7 @@ from django.conf import settings
...
@@ -2,7 +2,7 @@ from django.conf import settings
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.forms.fields
import
FileField
from
django.forms.fields
import
FileField
from
django.template.defaultfilters
import
filesizeformat
from
django.template.defaultfilters
import
filesizeformat
from
django.utils.translation
import
u
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
class
WagtailVideoField
(
FileField
):
class
WagtailVideoField
(
FileField
):
...
...
wagtailvideos/forms.py
View file @
2fe3bfdf
from
django
import
forms
from
django
import
forms
from
django.forms.models
import
modelform_factory
from
django.forms.models
import
modelform_factory
from
django.utils.translation
import
u
gettext
as
_
from
django.utils.translation
import
gettext
as
_
from
enumchoicefield.forms
import
EnumField
from
enumchoicefield.forms
import
EnumField
from
wagtail.admin
import
widgets
from
wagtail.admin
import
widgets
from
wagtail.admin.forms.collections
import
(
from
wagtail.admin.forms.collections
import
(
...
...
wagtailvideos/models.py
View file @
2fe3bfdf
...
@@ -17,7 +17,7 @@ from django.db import models
...
@@ -17,7 +17,7 @@ from django.db import models
from
django.forms.utils
import
flatatt
from
django.forms.utils
import
flatatt
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.translation
import
u
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
enumchoicefield
import
ChoiceEnum
,
EnumChoiceField
from
enumchoicefield
import
ChoiceEnum
,
EnumChoiceField
from
modelcluster.fields
import
ParentalKey
from
modelcluster.fields
import
ParentalKey
from
modelcluster.models
import
ClusterableModel
from
modelcluster.models
import
ClusterableModel
...
...
wagtailvideos/urls.py
View file @
2fe3bfdf
from
django.
conf.
urls
import
url
from
django.urls
import
path
,
re_path
from
wagtailvideos.views
import
chooser
,
multiple
,
videos
from
wagtailvideos.views
import
chooser
,
multiple
,
videos
app_name
=
'wagtailvideos'
app_name
=
'wagtailvideos'
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'^$'
,
videos
.
index
,
name
=
'index'
),
path
(
'add/'
,
videos
.
add
,
name
=
'add'
),
url
(
r
'^(\d+)/$'
,
videos
.
edit
,
name
=
'edit'
),
re_path
(
r
'^usage/(\d+)/$'
,
videos
.
usage
,
name
=
'video_usage'
),
url
(
r
'^(\d+)/delete/$'
,
videos
.
delete
,
name
=
'delete'
),
url
(
r
'^(\d+)/create_transcode/$'
,
videos
.
create_transcode
,
name
=
'create_transcode'
),
url
(
r
'^add/$'
,
videos
.
add
,
name
=
'add'
),
path
(
'multiple/add/'
,
multiple
.
add
,
name
=
'add_multiple'
),
url
(
r
'^usage/(\d+)/$'
,
videos
.
usage
,
name
=
'video_usage'
),
re_path
(
r
'^multiple/(\d+)/delete/$'
,
multiple
.
delete
,
name
=
'delete_multiple'
),
re_path
(
r
'^multiple/(\d+)/$'
,
multiple
.
edit
,
name
=
'edit_multiple'
),
url
(
r
'^multiple/add/$'
,
multiple
.
add
,
name
=
'add_multiple
'
),
path
(
'chooser/upload/'
,
chooser
.
chooser_upload
,
name
=
'chooser_upload
'
),
url
(
r
'^multiple/(\d+)/$'
,
multiple
.
edit
,
name
=
'edit_multiple
'
),
re_path
(
r
'^chooser/(\d+)/$'
,
chooser
.
video_chosen
,
name
=
'video_chosen
'
),
url
(
r
'^multiple/(\d+)/delete/$'
,
multiple
.
delete
,
name
=
'delete_multiple
'
),
path
(
'chooser/'
,
chooser
.
chooser
,
name
=
'chooser
'
),
url
(
r
'^chooser/$'
,
chooser
.
chooser
,
name
=
'chooser'
),
re_path
(
r
'^(\d+)/delete/$'
,
videos
.
delete
,
name
=
'delete'
),
url
(
r
'^chooser/(\d+)/$'
,
chooser
.
video_chosen
,
name
=
'video_chosen'
),
re_path
(
r
'^(\d+)/create_transcode/$'
,
videos
.
create_transcode
,
name
=
'create_transcode'
),
url
(
r
'^chooser/upload/$'
,
chooser
.
chooser_upload
,
name
=
'chooser_upload'
),
re_path
(
r
'^(\d+)/$'
,
videos
.
edit
,
name
=
'edit'
),
path
(
''
,
videos
.
index
,
name
=
'index'
),
]
]
wagtailvideos/views/multiple.py
View file @
2fe3bfdf
...
@@ -4,7 +4,7 @@ import wagtail
...
@@ -4,7 +4,7 @@ import wagtail
from
django.http
import
HttpResponseBadRequest
,
JsonResponse
from
django.http
import
HttpResponseBadRequest
,
JsonResponse
from
django.shortcuts
import
get_object_or_404
,
render
from
django.shortcuts
import
get_object_or_404
,
render
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.utils.encoding
import
force_
text
from
django.utils.encoding
import
force_
str
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.vary
import
vary_on_headers
from
django.views.decorators.vary
import
vary_on_headers
from
wagtail.search.backends
import
get_search_backends
from
wagtail.search.backends
import
get_search_backends
...
@@ -48,7 +48,7 @@ def add(request):
...
@@ -48,7 +48,7 @@ def add(request):
collections_to_choose
=
None
collections_to_choose
=
None
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
if
not
request
.
is_ajax
()
:
if
request
.
headers
.
get
(
'x-requested-with'
)
!=
'XMLHttpRequest'
:
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
if
not
request
.
FILES
:
if
not
request
.
FILES
:
...
@@ -83,7 +83,7 @@ def add(request):
...
@@ -83,7 +83,7 @@ def add(request):
'success'
:
False
,
'success'
:
False
,
# https://github.com/django/django/blob/stable/1.6.x/django/forms/util.py#L45
# https://github.com/django/django/blob/stable/1.6.x/django/forms/util.py#L45
'error_message'
:
'
\n
'
.
join
([
'
\n
'
.
join
([
force_
text
(
i
)
for
i
in
v
])
for
k
,
v
in
form
.
errors
.
items
()]),
'error_message'
:
'
\n
'
.
join
([
'
\n
'
.
join
([
force_
str
(
i
)
for
i
in
v
])
for
k
,
v
in
form
.
errors
.
items
()]),
})
})
else
:
else
:
form
=
VideoForm
()
form
=
VideoForm
()
...
@@ -104,7 +104,7 @@ def edit(request, video_id, callback=None):
...
@@ -104,7 +104,7 @@ def edit(request, video_id, callback=None):
video
=
get_object_or_404
(
Video
,
id
=
video_id
)
video
=
get_object_or_404
(
Video
,
id
=
video_id
)
if
not
request
.
is_ajax
()
:
if
request
.
headers
.
get
(
'x-requested-with'
)
!=
'XMLHttpRequest'
:
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
form
=
VideoForm
(
form
=
VideoForm
(
...
@@ -137,7 +137,7 @@ def edit(request, video_id, callback=None):
...
@@ -137,7 +137,7 @@ def edit(request, video_id, callback=None):
def
delete
(
request
,
video_id
):
def
delete
(
request
,
video_id
):
video
=
get_object_or_404
(
get_video_model
(),
id
=
video_id
)
video
=
get_object_or_404
(
get_video_model
(),
id
=
video_id
)
if
not
request
.
is_ajax
()
:
if
request
.
headers
.
get
(
'x-requested-with'
)
!=
'XMLHttpRequest'
:
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
return
HttpResponseBadRequest
(
"Cannot POST to this view without AJAX"
)
video
.
delete
()
video
.
delete
()
...
...
wagtailvideos/views/videos.py
View file @
2fe3bfdf
...
@@ -5,7 +5,7 @@ from django.conf import settings
...
@@ -5,7 +5,7 @@ from django.conf import settings
from
django.core.paginator
import
Paginator
from
django.core.paginator
import
Paginator
from
django.shortcuts
import
get_object_or_404
,
redirect
,
render
from
django.shortcuts
import
get_object_or_404
,
redirect
,
render
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils.translation
import
u
gettext
as
_
from
django.utils.translation
import
gettext
as
_
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.http
import
require_POST
from
django.views.decorators.vary
import
vary_on_headers
from
django.views.decorators.vary
import
vary_on_headers
from
wagtail.admin
import
messages
from
wagtail.admin
import
messages
...
@@ -60,7 +60,7 @@ def index(request):
...
@@ -60,7 +60,7 @@ def index(request):
page
=
paginator
.
get_page
(
request
.
GET
.
get
(
'p'
))
page
=
paginator
.
get_page
(
request
.
GET
.
get
(
'p'
))
# Create response
# Create response
if
request
.
is_ajax
()
:
if
request
.
headers
.
get
(
'x-requested-with'
)
==
'XMLHttpRequest'
:
response
=
render
(
request
,
'wagtailvideos/videos/results.html'
,
{
response
=
render
(
request
,
'wagtailvideos/videos/results.html'
,
{
'videos'
:
page
,
'videos'
:
page
,
'query_string'
:
query_string
,
'query_string'
:
query_string
,
...
...
wagtailvideos/wagtail_hooks.py
View file @
2fe3bfdf
from
django.conf.urls
import
include
,
url
from
django.conf.urls
import
include
from
django.templatetags.static
import
static
from
django.templatetags.static
import
static
from
django.urls
import
reverse
from
django.urls
import
path
,
reverse
from
django.utils.html
import
format_html
from
django.utils.html
import
format_html
from
django.utils.translation
import
u
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
wagtail.admin.edit_handlers
import
InlinePanel
from
wagtail.admin.edit_handlers
import
InlinePanel
from
wagtail.admin.menu
import
Menu
,
MenuItem
,
SubmenuMenuItem
from
wagtail.admin.menu
import
Menu
,
MenuItem
,
SubmenuMenuItem
from
wagtail.admin.search
import
SearchArea
from
wagtail.admin.search
import
SearchArea
...
@@ -43,7 +43,7 @@ if is_modeladmin_installed():
...
@@ -43,7 +43,7 @@ if is_modeladmin_installed():
@
hooks
.
register
(
'register_admin_urls'
)
@
hooks
.
register
(
'register_admin_urls'
)
def
register_admin_urls
():
def
register_admin_urls
():
return
[
return
[
url
(
r
'^
videos/'
,
include
(
urls
)),
path
(
'
videos/'
,
include
(
urls
)),
]
]
...
...
wagtailvideos/widgets.py
View file @
2fe3bfdf
import
json
import
json
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
u
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
as
_
from
wagtail.admin.widgets
import
AdminChooser
from
wagtail.admin.widgets
import
AdminChooser
from
wagtailvideos
import
get_video_model
from
wagtailvideos
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