Ejemplo n.º 1
0
def download_file(request, file, file_name):
    if request.user.is_authenticated() and has_permission(request, 'pastelsvg', 'can_download_protected_files'):
        download_file = get_object_or_404(ProtectedDownload, pk=file)
        responce =  HttpResponse('', content_type='')
        responce["X-Accel-Redirect"] =  download_file.file.url
        del responce['Content-Type']
        return responce
    else:
        raise Http404
Ejemplo n.º 2
0
def download(request):
    data = {}
    if not request.user.is_authenticated():
        pass
    elif not has_permission(request, 'pastelsvg', 'can_download_protected_files'):
        data = {
                "permission": False,
        }
    else:
        icon_group, icons = get_download('*****@*****.**')
        icon_group_large, icons_large = get_download('*****@*****.**')
        data = {
                "permission": True,
                "icon_group": icon_group,
                "icons": icons,
                "icon_group_large": icon_group_large,
                "icons_large": icons_large,
                "protected_files": ProtectedDownload.objects.filter(public=True).order_by('-release_date'),
        }
    data["title"] = "Pastel SVG Downloads"
    return render(request, 'pastelsvg/download.html' , data)