def add_video(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") common_page_data = get_common_page_data(request, course_prefix, course_suffix) if not common_page_data['is_course_admin']: return redirect('courses.views.view', course_prefix, course_suffix) index = len(Video.objects.filter(topic_id=request.POST.get("topic_id"))) draft_video = Video( course=common_page_data['draft_course'], topic_id=int(request.POST.get("topic_id")), title=request.POST.get("title"), #description=request.POST.get("description"), type='youtube', url=request.POST.get("yt_id"), slug=request.POST.get("slug"), mode='draft', index=index ) draft_video.save() draft_video.create_ready_instance() return redirect(request.META['HTTP_REFERER'])
def add_video(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") common_page_data = get_common_page_data(request, course_prefix, course_suffix) if not common_page_data['is_course_admin']: return redirect('courses.views.view', course_prefix, course_suffix) index = len(Video.objects.filter(topic_id=request.POST.get("topic_id"))) draft_video = Video( course=common_page_data['draft_course'], topic_id=int(request.POST.get("topic_id")), title=request.POST.get("title"), #description=request.POST.get("description"), type='youtube', url=request.POST.get("yt_id"), slug=request.POST.get("slug"), mode='draft', index=index) draft_video.save() draft_video.create_ready_instance() return redirect(request.META['HTTP_REFERER'])
def upload(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") common_page_data = get_common_page_data(request, course_prefix, course_suffix) data = {'common_page_data': common_page_data} if request.method == 'POST': # Need partial instance with course for form slug validation new_video = Video(course=common_page_data['course']) form = S3UploadForm(request.POST, request.FILES, course=common_page_data['course'], instance=new_video) if form.is_valid(): new_video.index = new_video.section.getNextIndex() new_video.mode = 'draft' new_video.handle = course_prefix + "--" + course_suffix # Bit of jiggery pokery to so that the id is set when the upload_path function is called. # Now storing file with id appended to the file path so that thumbnail and associated manifest files # are easily associated with the video by putting them all in the same directory. new_video.file = None new_video.save() new_video.file = form.cleaned_data['file'] new_video.save() new_video.create_ready_instance() #print new_video.file.url # TODO: don't hardcode the AWS location s3_path="https://s3-us-west-2.amazonaws.com/"+common_page_data['aws_storage_bucket_name']+"/"+urllib.quote_plus(new_video.file.name,"/") kelvinator.tasks.kelvinate.delay(s3_path, 2) if new_video.url: return redirect('courses.videos.views.list', course_prefix, course_suffix) authUrl = GetOAuth2Url(request, new_video) #eventually should store an access token, so they don't have to give permission everytime return redirect(authUrl) # return redirect("http://" + request.META['HTTP_HOST']) else: form = S3UploadForm(course=common_page_data['course']) data['form'] = form return render_to_response('videos/s3upload.html', data, context_instance=RequestContext(request))
def upload(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") exam_id = request.POST.get("exam_id", '') common_page_data = get_common_page_data(request, course_prefix, course_suffix) data = {'common_page_data': common_page_data} if request.method == 'POST': request.session['video_privacy'] = request.POST.get("video_privacy") # Need partial instance with course for form slug validation new_video = Video(course=common_page_data['course']) form = S3UploadForm(request.POST, request.FILES, course=common_page_data['course'], instance=new_video) if form.is_valid(): new_video.index = new_video.section.getNextIndex() new_video.mode = 'draft' new_video.handle = course_prefix + "--" + course_suffix if exam_id: try: exam = Exam.objects.get(id=exam_id) except Exam.DoesNotExist: return HttpResponseBadRequest( "The exam you wanted to link to this video was not found!" ) new_video.exam = exam exam.live_datetime = new_video.live_datetime exam.save() if exam.image: exam.image.live_datetime = new_video.live_datetime exam.image.save() # Bit of jiggery pokery to so that the id is set when the upload_path function is called. # Now storing file with id appended to the file path so that thumbnail and associated manifest files # are easily associated with the video by putting them all in the same directory. new_video.file = None new_video.save() new_video.create_ready_instance() new_video.file = form.cleaned_data['file'] new_video.save() new_video.commit() # kick off remote jobs kelvinator.tasks.kelvinate.delay(new_video.file.name) kelvinator.tasks.resize.delay(new_video.file.name, "large") kelvinator.tasks.resize.delay(new_video.file.name, "small") if new_video.url: return redirect('courses.videos.views.list', course_prefix, course_suffix) authUrl = GetOAuth2Url(request, new_video) #eventually should store an access token, so they don't have to give permission everytime return redirect(authUrl) else: form = S3UploadForm(course=common_page_data['course']) data['form'] = form return render_to_response('videos/s3upload.html', data, context_instance=RequestContext(request))
def upload(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") exam_id = request.POST.get("exam_id",'') common_page_data = get_common_page_data(request, course_prefix, course_suffix) data = {'common_page_data': common_page_data} if request.method == 'POST': request.session['video_privacy'] = request.POST.get("video_privacy") # Need partial instance with course for form slug validation new_video = Video(course=common_page_data['course']) form = S3UploadForm(request.POST, request.FILES, course=common_page_data['course'], instance=new_video) if form.is_valid(): new_video.index = new_video.section.getNextIndex() new_video.mode = 'draft' new_video.handle = course_prefix + "--" + course_suffix if exam_id: try: exam = Exam.objects.get(id=exam_id) except Exam.DoesNotExist: return HttpResponseBadRequest("The exam you wanted to link to this video was not found!") new_video.exam = exam exam.live_datetime = new_video.live_datetime exam.save() if exam.image: exam.image.live_datetime = new_video.live_datetime exam.image.save() # Bit of jiggery pokery to so that the id is set when the upload_path function is called. # Now storing file with id appended to the file path so that thumbnail and associated manifest files # are easily associated with the video by putting them all in the same directory. new_video.file = None new_video.save() new_video.file = form.cleaned_data['file'] new_video.save() new_video.create_ready_instance() #print new_video.file.url # kick off remote jobs kelvinator.tasks.kelvinate.delay(new_video.file.name) kelvinator.tasks.resize.delay(new_video.file.name, "large") kelvinator.tasks.resize.delay(new_video.file.name, "small") if new_video.url: return redirect('courses.videos.views.list', course_prefix, course_suffix) authUrl = GetOAuth2Url(request, new_video) #eventually should store an access token, so they don't have to give permission everytime return redirect(authUrl) # return redirect("http://" + request.META['HTTP_HOST']) else: form = S3UploadForm(course=common_page_data['course']) data['form'] = form return render_to_response('videos/s3upload.html', data, context_instance=RequestContext(request))
def upload(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") common_page_data = get_common_page_data(request, course_prefix, course_suffix) data = {'common_page_data': common_page_data} if request.method == 'POST': # Need partial instance with course for form slug validation new_video = Video(course=common_page_data['course']) form = S3UploadForm(request.POST, request.FILES, course=common_page_data['course'], instance=new_video) if form.is_valid(): new_video.index = new_video.section.getNextIndex() new_video.mode = 'draft' new_video.handle = course_prefix + "--" + course_suffix # Bit of jiggery pokery to so that the id is set when the upload_path function is called. # Now storing file with id appended to the file path so that thumbnail and associated manifest files # are easily associated with the video by putting them all in the same directory. new_video.file = None new_video.save() new_video.file = form.cleaned_data['file'] new_video.save() new_video.create_ready_instance() print new_video.file.url # TODO: don't hardcode the AWS location s3_path = "https://s3-us-west-2.amazonaws.com/" + common_page_data[ 'aws_storage_bucket_name'] + "/" + urllib.quote_plus( new_video.file.name, "/") # TODO: make these parameters settable kelvinator.tasks.run.delay(s3_path, "1", "1000") if new_video.url: return redirect('courses.videos.views.list', course_prefix, course_suffix) authUrl = GetOAuth2Url(request, new_video) #eventually should store an access token, so they don't have to give permission everytime return redirect(authUrl) # return redirect("http://" + request.META['HTTP_HOST']) else: form = S3UploadForm(course=common_page_data['course']) data['form'] = form return render_to_response('videos/s3upload.html', data, context_instance=RequestContext(request))
def upload(request): course_prefix = request.POST.get("course_prefix") course_suffix = request.POST.get("course_suffix") common_page_data = get_common_page_data(request, course_prefix, course_suffix) data = {'common_page_data': common_page_data} if request.method == 'POST': # Need partial instance with course for form slug validation new_video = Video(course=common_page_data['course']) form = S3UploadForm(request.POST, request.FILES, course=common_page_data['course'], instance=new_video) if form.is_valid(): new_video = form.save(commit=False) new_video.index = new_video.section.getNextIndex() new_video.mode = 'staging' new_video.handle = course_prefix + "#$!" + course_suffix # Bit of jiggery pokery to so that the id is set when the upload_path function is called. # Now storing file with id appended to the file path so that thumbnail and associated manifest files # are easily associated with the video by putting them all in the same directory. new_video.file = None new_video.save() new_video.file = form.cleaned_data['file'] new_video.save() new_video.create_production_instance() print new_video.file.url print new_video.url if new_video.url: return redirect('courses.videos.views.list', course_prefix, course_suffix) authUrl = GetOAuth2Url(request, new_video) #eventually should store an access token, so they don't have to give permission everytime return redirect(authUrl) # return redirect("http://" + request.META['HTTP_HOST']) else: form = S3UploadForm(course=common_page_data['course']) data['form'] = form return render_to_response('videos/s3upload.html', data, context_instance=RequestContext(request))