Exemplo n.º 1
0
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:
        form = VideoForm()

    videos = Video.objects.order_by('title')
    paginator = Paginator(videos, per_page=12)
    page = paginator.get_page(request.GET.get('p'))

    return render_modal_workflow(
        request, 'wagtailvideos/chooser/chooser.html', None,
        template_vars={'videos': page, 'uploadform': form, 'searchform': searchform},
        json_data=get_chooser_js_data()
    )
Exemplo n.º 2
0
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, 'wagtailvideos/chooser/video_chosen.js',
                {'video_json': get_video_json(video)}
            )
    else:
        form = VideoForm()

    videos = Video.objects.order_by('title')
    paginator, videos = paginate(request, videos, per_page=12)

    return render_modal_workflow(
        request, 'wagtailvideos/chooser/chooser.html', 'wagtailvideos/chooser/chooser.js',
        {'videos': videos, 'uploadform': form, 'searchform': searchform}
    )
Exemplo n.º 3
0
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, 'wagtailvideos/chooser/video_chosen.js',
                {'video_json': get_video_json(video)}
            )
    else:
        form = VideoForm()

    videos = Video.objects.order_by('title')
    paginator, videos = paginate(request, videos, per_page=12)

    return render_modal_workflow(
        request, 'wagtailvideos/chooser/chooser.html', 'wagtailvideos/chooser/chooser.js',
        {'videos': videos, 'uploadform': form, 'searchform': searchform}
    )