Пример #1
0
 def test_complete_upload_unicode(self, _ticket_request):
     """
     Filenames passed to complete_upload should be encoded in ASCII, with
     non-ASCII being encoded using HTML/XML entities.
     """
     vimeo.complete_upload('1234', u'Basket ball à')
     _ticket_request.assert_called_with('vimeo.videos.upload.complete',
                                        'POST',
                                        ticket_id='1234',
                                        filename='Basket ball à',
                                        error_msg=ANY)
Пример #2
0
 def test_complete_upload_unicode(self, _ticket_request):
     """
     Filenames passed to complete_upload should be encoded in ASCII, with
     non-ASCII being encoded using HTML/XML entities.
     """
     vimeo.complete_upload('1234', u'Basket ball à')
     _ticket_request.assert_called_with('vimeo.videos.upload.complete',
                                        'POST',
                                        ticket_id='1234',
                                        filename='Basket ball à',
                                        error_msg=ANY)
Пример #3
0
def upload(request):
    ticket = request.session.get('vimeo_ticket', None)
    form = VideoForm(request.POST or None)
    if ticket and request.method == 'POST' and form.is_valid():
        # Verify that the filesize from the client matches what vimeo received.
        # Some browsers don't provide this number, so we can't really verify.
        filesize = form.cleaned_data['filesize']
        if filesize and not vimeo.verify_chunks(ticket['id'], filesize):
            return upload_error(request)

        ticket = vimeo.complete_upload(ticket['id'],
                                       form.cleaned_data['filename'])

        # Create video and schedule it for processing.
        video = form.save(commit=False)
        video.user = request.user
        video.vimeo_id = ticket['video_id']
        video.save()
        tasks.process_video.delay(video.id)

        del request.session['vimeo_ticket']
        return redirect('flicks.videos.upload_complete')

    # Generate an upload token if one doesn't exist or isn't valid.
    if not ticket or not vimeo.is_ticket_valid(ticket['id']):
        ticket = vimeo.get_new_ticket()
        request.session['vimeo_ticket'] = ticket

    return render(request, 'videos/upload.html', {
        'ticket': ticket,
        'form': form
    })
Пример #4
0
def upload(request):
    ticket = request.session.get('vimeo_ticket', None)
    form = VideoForm(request.POST or None)
    if ticket and request.method == 'POST' and form.is_valid():
        # Verify that the filesize from the client matches what vimeo received.
        # Some browsers don't provide this number, so we can't really verify.
        filesize = form.cleaned_data['filesize']
        if filesize and not vimeo.verify_chunks(ticket['id'], filesize):
            return upload_error(request)

        ticket = vimeo.complete_upload(ticket['id'],
                                       form.cleaned_data['filename'])

        # Create video and schedule it for processing.
        video = form.save(commit=False)
        video.user = request.user
        video.vimeo_id = ticket['video_id']
        video.save()
        tasks.process_video.delay(video.id)

        del request.session['vimeo_ticket']
        return redirect('flicks.videos.upload_complete')

    # Generate an upload token if one doesn't exist or isn't valid.
    if not ticket or not vimeo.is_ticket_valid(ticket['id']):
        ticket = vimeo.get_new_ticket()
        request.session['vimeo_ticket'] = ticket

    return render(request, 'videos/upload.html', {
        'ticket': ticket,
        'form': form
    })
Пример #5
0
    def test_complete_upload(self, _ticket_request):
        """Return the ticket given by Vimeo after completing the upload."""
        _ticket_request.return_value = {'stat': 'ok', 'ticket': {'some': 'dat'}}
        eq_(vimeo.complete_upload('id', 'some_filename.png'), {'some': 'dat'})

        error_msg = _ticket_request.call_args[1]['error_msg']
        ok_('some_filename.png' in error_msg)
Пример #6
0
    def test_complete_upload(self, _ticket_request):
        """Return the ticket given by Vimeo after completing the upload."""
        _ticket_request.return_value = {
            'stat': 'ok',
            'ticket': {
                'some': 'dat'
            }
        }
        eq_(vimeo.complete_upload('id', 'some_filename.png'), {'some': 'dat'})

        error_msg = _ticket_request.call_args[1]['error_msg']
        ok_('some_filename.png' in error_msg)
Пример #7
0
 def test_complete_upload(self, _ticket_request):
     """Return the ticket given by Vimeo after completing the upload."""
     _ticket_request.return_value = {'stat': 'ok', 'ticket': {'some': 'dat'}}
     eq_(vimeo.complete_upload('id', 'filename'), {'some': 'dat'})