Esempio n. 1
0
def upload_printfacet_image(request):
    """ Add image to a printfacet."""

    if request.method == 'POST':
        imageform=ImageAssetForm(request.POST, request.FILES)
        if imageform.is_valid():
            printimage = imageform.save(commit=False)
            # retrieve the printfacet the image should be associated with
            printfacet_id = request.POST.get('printfacet')
            printfacet = get_object_or_404(PrintFacet, id=printfacet_id)
            # set request based attributes
            printimage.owner = request.user
            printimage.organization = request.user.organization
            printimage.save()
            # add image asset to printfacet image_assets
            printfacet.image_assets.add(printimage)
            printfacet.save()
    return redirect('story_detail', pk=printfacet.story.id)
Esempio n. 2
0
def upload_videofacet_image(request):
    """ Add image to a videofacet."""

    if request.method == 'POST':
        imageform=ImageAssetForm(request.POST, request.FILES)
        if imageform.is_valid():
            videoimage = imageform.save(commit=False)
            # retrieve the videofacet the image should be associated with
            videofacet_id = request.POST.get('videofacet')
            videofacet = get_object_or_404(VideoFacet, id=videofacet_id)
            # set request based attributes
            videoimage.owner = request.user
            videoimage.organization = request.user.organization
            videoimage.save()
            # add image asset to videofacet image_assets
            videofacet.image_assets.add(videoimage)
            videofacet.save()
    return redirect('story_detail', pk=videofacet.story.id)
Esempio n. 3
0
def upload_webfacet_image(request):
    """ Add image to a webfacet."""

    if request.method == 'POST':
        imageform=ImageAssetForm(request.POST, request.FILES)
        if imageform.is_valid():
            webimage = imageform.save(commit=False)
            # retrieve the webfacet the image should be associated with
            webfacet_id = request.POST.get('webfacet')
            webfacet = get_object_or_404(WebFacet, id=webfacet_id)
            # set request based attributes
            webimage.owner = request.user
            webimage.organization = request.user.organization
            webimage.save()
            # add image asset to webfacet image_assets
            webfacet.image_assets.add(webimage)
            webfacet.save()
    return redirect('story_detail', pk=webfacet.story.id)
Esempio n. 4
0
def image_asset_detail(request, pk):
    """ Display detail information for a specific image asset."""

    image = get_object_or_404(ImageAsset, id=pk)
    image_usage = ImageAsset.get_image_usage(image)

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

    return render(request, 'editorial/assetdetail_image.html', {
        'image': image,
        'image_usage': image_usage,
        'editimageform': editimageform,
    })
Esempio n. 5
0
def upload_image(request):
    """ Add image to a facet."""

    if request.method == 'POST':
        imageform=ImageAssetForm(request.POST, request.FILES)
        if imageform.is_valid():
            image = imageform.save(commit=False)

            # retrieve the facet the image 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
            image.owner = request.user
            image.organization = request.user.organization
            image.save()

            # add image asset to facet image_assets
            facet.image_assets.add(image)
            facet.save()

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

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