def as_rtf(request, document_id): form = RTFForm(request.POST) if not form.is_valid(): return HttpResponseRedirect(reverse('browse_detail', args=[document_id])) document = Document.objects.get(pk=document_id) inputFile = document.latest_version().content.path outputFile = "/tmp/%s.rtf" % document_id DaisyPipeline.dtbook2rtf(inputFile, outputFile, **form.cleaned_data) return render_to_mimetype_response('application/rtf', document.title.encode('utf-8'), outputFile)
def preview_rtf(request, document_id): document = get_object_or_404(Document, pk=document_id) if request.method == 'POST': form = RTFForm(request.POST) if form.is_valid(): inputFile = document.latest_version().content.path outputFile = "/tmp/%s.rtf" % document_id DaisyPipeline.dtbook2rtf(inputFile, outputFile, **form.cleaned_data) return render_to_mimetype_response('application/rtf', document.title.encode('utf-8'), outputFile) else: form = RTFForm() return render(request, 'documents/todo_rtf.html', locals())