예제 #1
0
파일: views.py 프로젝트: panuta/openreader
def download_publication(request, publication_uid):
    publication = get_object_or_404(Publication, uid=publication_uid)

    if not get_permission_backend(request).can_view_publication(request.user, publication.organization, {'publication':publication}):
        raise Http404

    return private_files_get_file(request, 'domain', 'Publication', 'uploaded_file', str(publication.id), '%s.%s' % (publication.original_file_name, publication.file_ext))
예제 #2
0
파일: views.py 프로젝트: panuta/openreader
def request_download_publication(request, publication_uid):
    try:
        publication = Publication.objects.get(uid=publication_uid)
    except Publication.DoesNotExist:
        return HttpResponse('Page not found', status=404)

    user = _extract_user(request)

    try:
        user_organization = UserOrganization.objects.get(organization=publication.organization, user=user, is_active=True)
    except:
        return HttpResponse('No permissions', status=403)

    if not get_permission_backend(request).get_publication_access(user, publication):
        return HttpResponse('No permissions', status=403)

    # ----- CDN support is not available for NBTC -----
    # server_urls = []
    # for server in OrganizationDownloadServer.objects.filter(organization=publication.organization).order_by('-priority'):
    #     download_url = generate_download_url(server, publication)
    #     if download_url:
    #         server_urls.append(download_url)
    # return HttpResponse(simplejson.dumps(server_urls))

    return private_files_get_file(request, 'domain', 'Publication', 'uploaded_file', str(publication.id), '%s.%s' % (publication.original_file_name, publication.file_ext))
예제 #3
0
def download_report_attachment(request, uid):
    attachment = get_object_or_404(ReportSubmissionAttachment, uid=uid)
    return private_files_get_file(request, 'report', 'ReportSubmissionAttachment', 'attachment', str(attachment.id), '%s.%s' % (attachment.file_name, attachment.file_ext))