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
914a5ead
Commit
914a5ead
authored
Oct 03, 2022
by
13hakta
Browse files
[perms] Add permission to choose collections
parent
f7e32ed2
Changes
4
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/forms.py
View file @
914a5ead
...
...
@@ -77,6 +77,7 @@ GroupVideoPermissionFormSet = collection_member_permission_formset_factory(
[
(
'add_video'
,
_
(
"Add"
),
_
(
"Add/edit videos you own"
)),
(
'change_video'
,
_
(
"Edit"
),
_
(
"Edit any video"
)),
(
'choose_video'
,
_
(
"Choose"
),
_
(
"Choose video"
)),
],
'wagtailvideos/permissions/includes/video_permissions_formset.html'
)
wagtailvideos/models.py
View file @
914a5ead
...
...
@@ -245,6 +245,9 @@ class Video(AbstractVideo):
class
Meta
:
ordering
=
[
'-created_at'
]
permissions
=
[
(
"choose_video"
,
"Can choose video"
),
]
class
TranscodingThread
(
threading
.
Thread
):
...
...
wagtailvideos/views/chooser.py
View file @
914a5ead
...
...
@@ -68,6 +68,12 @@ def chooser(request):
if
collection_id
:
videos
=
videos
.
filter
(
collection
=
collection_id
)
collections
=
permission_policy
.
collections_user_has_any_permission_for
(
request
.
user
,
[
'choose'
])
if
len
(
collections
)
>
0
:
videos
=
videos
.
filter
(
collection__in
=
collections
)
searchform
=
SearchForm
(
request
.
GET
)
if
searchform
.
is_valid
():
q
=
searchform
.
cleaned_data
[
'q'
]
...
...
@@ -93,7 +99,10 @@ def chooser(request):
else
:
searchform
=
SearchForm
()
collections
=
Collection
.
objects
.
all
()
collections
=
permission_policy
.
collections_user_has_permission_for
(
request
.
user
,
'choose'
)
if
len
(
collections
)
<
2
:
collections
=
None
...
...
wagtailvideos/views/videos.py
View file @
914a5ead
...
...
@@ -28,14 +28,14 @@ else:
permission_checker
=
PermissionPolicyChecker
(
permission_policy
)
@
permission_checker
.
require_any
(
'add'
,
'change'
,
'delete'
)
@
permission_checker
.
require_any
(
'add'
,
'change'
,
'delete'
,
'choose'
)
@
vary_on_headers
(
'X-Requested-With'
)
def
index
(
request
):
# Get Videos (filtered by user permission)
Video
=
get_video_model
()
collections
=
permission_policy
.
collections_user_has_any_permission_for
(
request
.
user
,
[
'add'
,
'change'
,
'delete'
])
request
.
user
,
[
'add'
,
'change'
,
'delete'
,
'choose'
])
if
len
(
collections
)
>
1
:
collections_to_choose
=
collections
else
:
...
...
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