Exemple #1
0
def viewFileFromTicket(request, ticketuuid, filename):
    try:
        tick = ticket.Ticket.objects.get(unid=ticketuuid)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    try:
        resfile = UploadedFileTicket.objects.get(for_ticket=tick,
                                                 filename=filename)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    response = HttpResponse(resfile.uplfile.read(), 'image')
    return response
Exemple #2
0
def downloadSettingsFile(request, clientid):
    try:
        router = Router.objects.get(company_id=clientid)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    if not router.settings_file_available():
        return error_views.notfound(request)
    chunk_size = 8192
    response = StreamingHttpResponse(FileWrapper(router.settings_file, chunk_size),
                            content_type=mimetypes.guess_type(router.settings_file.path)[0])
    response['Content-Length'] = os.path.getsize(router.settings_file.path)    
    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(os.path.basename(router.settings_file.path))
    return response
Exemple #3
0
def viewFileFromComment(request, ticketuuid, commentid, filename):
    try:
        comment = ticket_comment.TicketComment.objects.get(id=commentid)
        if comment.initial_ticket.unid != ticketuuid:
            return error_views.notfound(request)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    try:
        resfile = UploadedFileTicket.objects.get(for_ticket=comment,
                                                 filename=filename)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    response = HttpResponse(resfile.uplfile.read(), 'image')
    return response
Exemple #4
0
def downloadFileFromTicket(request, ticketuuid, filename):
    try:
        tick = ticket.Ticket.objects.get(unid=ticketuuid)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    try:
        resfile = UploadedFileTicket.objects.get(for_ticket=tick,
                                                 filename=filename)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    response = HttpResponse(resfile.uplfile.read())
    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(
        os.path.basename(resfile.uplfile.name))
    response['X-Sendfile'] = smart_str(resfile.uplfile.name)
    return response
Exemple #5
0
def SecretNoteViewExternalClose(request, noteuuid):
    valid, response = main_views.initRequest(request)
    if not valid:
        return response
    data = modelgetters.form_one_note_data_external(noteuuid)
    if data is None:
        return error_views.notfound(request)
    data['PAGE_TITLE'] = 'Secret Note: CMS infotek'
    data['built'] = datetime.now().strftime("%H:%M:%S")
    return render(request, 'views/secretnoteclose.html', data, content_type='text/html')
Exemple #6
0
def downloadFileFromComment(request, ticketuuid, commentid, filename):
    try:
        comment = ticket_comment.TicketComment.objects.get(id=commentid)
        if comment.initial_ticket.unid != ticketuuid:
            return error_views.notfound(request)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    try:
        resfile = UploadedFileTicket.objects.get(for_ticket=comment,
                                                 filename=filename)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    response = HttpResponse()
    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(
        os.path.basename(resfile.uplfile.name))
    response['X-Sendfile'] = smart_str(resfile.uplfile.name)
    return response
Exemple #7
0
def downloadFileFromTools(request, tooluuid):
    try:
        tool = FileTool.objects.get(unid=tooluuid)
    except Exception as exc:
        print(exc)
        return error_views.notfound(request)
    if tool.public or request.user.is_authenticated:
        chunk_size = 8192
        response = StreamingHttpResponse(FileWrapper(tool.uplfile, chunk_size),
                                         content_type=mimetypes.guess_type(
                                             tool.uplfile.path)[0])
        response['Content-Length'] = os.path.getsize(tool.uplfile.path)
        response[
            'Content-Disposition'] = 'attachment; filename=%s' % smart_str(
                os.path.basename(tool.uplfile.path))
        return response
    else:
        return redirect(
            reverse("download_tool", kwargs={'tooluuid': tool.unid}))