Esempio n. 1
0
def retrieve_download(request,
                      download_id,
                      template="soil/file_download.html",
                      extra_context=None):
    """
    Retrieve a download that's waiting to be generated. If it is the get_file,
    then download it, else, let the ajax on the page poll.
    """
    context = RequestContext(request)
    if extra_context:
        context.update(extra_context)
    context['download_id'] = download_id

    if 'get_file' in request.GET:
        download = DownloadBase.get(download_id)
        if download is None:
            logging.error(
                "Download file request for expired/nonexistent file requested")
            raise Http404
        if download.owner_ids and request.couch_user.get_id not in download.owner_ids:
            return HttpResponseForbidden(
                _("You do not have access to this file. It can only be downloaded by the user who created it"
                  ))

        return download.toHttpResponse()

    return render(request, template, context=context.flatten())
Esempio n. 2
0
def retrieve_download(request, download_id, template="soil/file_download.html", extra_context=None):
    """
    Retrieve a download that's waiting to be generated. If it is the get_file, 
    then download it, else, let the ajax on the page poll.
    """
    context = RequestContext(request)
    if extra_context:
        context.update(extra_context)
    context['download_id'] = download_id

    if 'get_file' in request.GET:
        download = DownloadBase.get(download_id)
        if download is None:
            logging.error("Download file request for expired/nonexistent file requested")
            raise Http404
        return download.toHttpResponse()

    return render_to_response(template, context=context.flatten())
Esempio n. 3
0
def retrieve_download(request, download_id, template="soil/file_download.html", extra_context=None):
    """
    Retrieve a download that's waiting to be generated. If it is the get_file,
    then download it, else, let the ajax on the page poll.
    """
    context = RequestContext(request)
    if extra_context:
        context.update(extra_context)
    context['download_id'] = download_id

    if 'get_file' in request.GET:
        download = DownloadBase.get(download_id)
        if download is None:
            logging.error("Download file request for expired/nonexistent file requested")
            raise Http404
        return download.toHttpResponse()

    return render_to_response(template, context=context.flatten())