Example #1
0
def audio_asset_detail(request, pk):
    """ Display detail information for a specific audio asset."""

    audio = get_object_or_404(AudioAsset, id=pk)
    audio_usage = AudioAsset.get_audio_usage(audio)

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

    return render(request, 'editorial/assetdetail_audio.html', {
        'audio': audio,
        'audio_usage': audio_usage,
        'editaudioform': editaudioform,
    })
Example #2
0
    def item_audio_assets(self):
        """Return all audio assets associated with an item and the forms to associate more."""

        self.object = self.get_object()
        audio = self.object.get_item_audio()
        audio_library = self.object.get_audio_library()
        uploadform = AudioAssetForm()
        return {
            'audio': audio,
            'audio_library': audio_library,
            'uploadform': uploadform
        }
Example #3
0
def upload_audio(request):
    """ Add audio to a facet."""

    if request.method == 'POST':
        audioform=AudioAssetForm(request.POST, request.FILES)
        if audioform.is_valid():
            audio = audioform.save(commit=False)

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

            # add audio asset to webfacet audio_assets
            facet.audio_assets.add(audio)
            facet.save()

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

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