Convert the document image view to use queued conversion

This commit is contained in:
Roberto Rosario
2014-10-03 16:34:54 -04:00
parent 3b1937bb17
commit 831b63ba77

View File

@@ -53,6 +53,7 @@ from .permissions import (PERMISSION_DOCUMENT_PROPERTIES_EDIT,
from .runtime import storage_backend
from .settings import (PREVIEW_SIZE, RECENT_COUNT, ROTATION_STEP,
ZOOM_PERCENT_STEP, ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL)
from .tasks import task_get_document_image
logger = logging.getLogger(__name__)
@@ -265,6 +266,7 @@ def document_edit(request, document_id):
}, context_instance=RequestContext(request))
# TODO: Get rid of this view and convert widget to use API and base64 only images
def get_document_image(request, document_id, size=PREVIEW_SIZE):
document = get_object_or_404(Document, pk=document_id)
try:
@@ -286,7 +288,8 @@ def get_document_image(request, document_id, size=PREVIEW_SIZE):
rotation = int(request.GET.get('rotation', DEFAULT_ROTATION)) % 360
return sendfile.sendfile(request, document.get_image(size=size, page=page, zoom=zoom, rotation=rotation, version=version), mimetype=DEFAULT_FILE_FORMAT_MIMETYPE)
task = task_get_document_image.apply_async(kwargs=dict(document_id=document.pk, size=size, page=page, zoom=zoom, rotation=rotation, as_base64=False, version=version), queue='converter')
return sendfile.sendfile(request, task.get(timeout=1), mimetype=DEFAULT_FILE_FORMAT_MIMETYPE)
def document_download(request, document_id=None, document_id_list=None, document_version_pk=None):