Ejemplo n.º 1
0
def video_asset_detail(request, pk):
    """ Display detail information for a specific video asset."""

    video = get_object_or_404(VideoAsset, id=pk)
    video_usage = VideoAsset.get_video_usage(video)

    if request.method =="POST":
        editvideoform = VideoAssetForm(data=request.POST, instance=video)
        if editvideoform.is_valid():
            editvideoform.save()
            #record action for activity stream
            action.send(request.user, verb="updated", action_object=video)
            return redirect('asset_detail', pk=video.id)
    else:
        editvideoform = VideoAssetForm(instance=video)

    return render(request, 'editorial/assetdetail_video.html', {
        'video': video,
        'video_usage': video_usage,
        'editvideoform': editvideoform,
    })
Ejemplo n.º 2
0
def upload_video(request):
    """ Add video to a facet."""

    if request.method == 'POST':
        videoform=VideoAssetForm(request.POST, request.FILES)
        if videoform.is_valid():
            video = videoform.save(commit=False)

            # retrieve the facet the video should be associated with
            facet_type = request.POST.get('type')
            if facet_type == "webfacet":
                facet_id = request.POST.get('webfacet')
                facet = get_object_or_404(WebFacet, id=facet_id)
            elif facet_type == "printfacet":
                facet_id = request.POST.get('printfacet')
                facet = get_object_or_404(PrintFacet, id=facet_id)
            elif facet_type == "audiofacet":
                facet_id = request.POST.get('audiofacet')
                facet = get_object_or_404(AudioFacet, id=facet_id)
            elif facet_type == "videofacet":
                facet_id = request.POST.get('videofacet')
                facet = get_object_or_404(VideoFacet, id=facet_id)

            # set request based attributes
            video.owner = request.user
            video.organization = request.user.organization
            video.save()

            # add video asset to facet video_assets
            facet.video_assets.add(video)
            facet.save()

            # record action for activity stream
            action.send(request.user, verb="uploaded video", action_object=video, target=facet)

    return redirect('story_detail', pk=facet.story.id)