How to use the wagtailvideos.models.Video function in wagtailvideos

To help you get started, we’ve selected a few wagtailvideos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neon-jungle / wagtailvideos / wagtailvideos / views / multiple.py View on Github external
def edit(request, video_id, callback=None):
    VideoForm = get_video_edit_form(Video)

    video = get_object_or_404(Video, id=video_id)

    if not request.is_ajax():
        return HttpResponseBadRequest("Cannot POST to this view without AJAX")

    form = VideoForm(
        request.POST, request.FILES, instance=video, prefix='video-' + video_id
    )

    if form.is_valid():
        form.save()

        # Reindex the image to make sure all tags are indexed
        for backend in get_search_backends():
            backend.add(video)

        return JsonResponse({
github neon-jungle / wagtailvideos / wagtailvideos / permissions.py View on Github external
from __future__ import absolute_import, print_function, unicode_literals

from wagtail.wagtailcore.permission_policies.collections import \
    CollectionOwnershipPermissionPolicy

from wagtailvideos.models import Video

permission_policy = CollectionOwnershipPermissionPolicy(
    Video,
    auth_model=Video,
    owner_field_name='uploaded_by_user'
)
github neon-jungle / wagtailvideos / wagtailvideos / jinja2tags.py View on Github external
def video(video, **attrs):
    if isinstance(video, Video):
        defaults = {'preload': True, 'controls': True}
        defaults.update(attrs)
        return video.video_tag(attrs)
    else:
        raise TypeError('Expected type {0}, received {1}.'.format(Video, type(video)))
github neon-jungle / wagtailvideos / wagtailvideos / views / chooser.py View on Github external
def chooser_upload(request):
    VideoForm = get_video_form(Video)

    searchform = SearchForm()

    if request.POST:
        video = Video(uploaded_by_user=request.user)
        form = VideoForm(request.POST, request.FILES, instance=video)

        if form.is_valid():
            video.uploaded_by_user = request.user
            video.save()

            # Reindex the video to make sure all tags are indexed
            search_index.insert_or_update_object(video)

            return render_modal_workflow(
                request, None, json_data={
                    'step': 'video_chosen',
                    'result': get_video_json(video)
                }
            )
    else:
github neon-jungle / wagtailvideos / wagtailvideos / views / videos.py View on Github external
def create_transcode(request, video_id):
    if request.method != 'POST':
        return HttpResponseNotAllowed(['POST'])
    video = get_object_or_404(Video, id=video_id)
    transcode_form = VideoTranscodeAdminForm(data=request.POST, video=video)

    if transcode_form.is_valid():
        transcode_form.save()
    return redirect('wagtailvideos:edit', video_id)
github neon-jungle / wagtailvideos / wagtailvideos / forms.py View on Github external
class VideoTranscodeAdminForm(forms.Form):
    media_format = EnumField(MediaFormats)
    quality = EnumField(VideoQuality)

    def __init__(self, video, data=None, **kwargs):
        super(VideoTranscodeAdminForm, self).__init__(data=data, **kwargs)
        self.video = video

    def save(self):
        media_format = self.cleaned_data['media_format']
        quality = self.cleaned_data['quality']
        self.video.do_transcode(media_format, quality)


GroupVideoPermissionFormSet = collection_member_permission_formset_factory(
    Video,
    [
        ('add_video', _("Add"), _("Add/edit images you own")),
        ('change_video', _("Edit"), _("Edit any video")),
    ],
    'wagtailvideos/permissions/includes/video_permissions_formset.html'
)
github neon-jungle / wagtailvideos / wagtailvideos / permissions.py View on Github external
from __future__ import absolute_import, print_function, unicode_literals

from wagtail.wagtailcore.permission_policies.collections import \
    CollectionOwnershipPermissionPolicy

from wagtailvideos.models import Video

permission_policy = CollectionOwnershipPermissionPolicy(
    Video,
    auth_model=Video,
    owner_field_name='uploaded_by_user'
)
github neon-jungle / wagtailvideos / wagtailvideos / widgets.py View on Github external
def __init__(self, **kwargs):
        super(AdminVideoChooser, self).__init__(**kwargs)
        self.video_model = Video