Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def is_editable_by_user(self, user):
from wagtailvideos.permissions import permission_policy
return permission_policy.user_has_permission_for_instance(user, 'change', self)
if not video._meta.get_field('file').storage.exists(video.file.name):
# Give error if image file doesn't exist
messages.error(request, _(
"The source video file could not be found. Please change the source or delete the video."
).format(video.title), buttons=[
messages.button(reverse('wagtailvideos:delete', args=(video.id,)), _('Delete'))
])
return render(request, "wagtailvideos/videos/edit.html", {
'video': video,
'form': form,
'filesize': video.get_file_size(),
'can_transcode': ffmpeg.installed(),
'transcodes': video.transcodes.all(),
'transcode_form': VideoTranscodeAdminForm(video=video),
'user_can_delete': permission_policy.user_has_permission_for_instance(request.user, 'delete', video)
})