def invoice_download(request, pk): """https://github.com/johnsensible/django-sendfile""" invoice = get_object_or_404(Invoice, pk=pk) check_perm(request.user, invoice.contact) return sendfile(request, invoice.pdf.path, attachment=True, attachment_filename='{}.pdf'.format( invoice.invoice_number))
def invoice_download(request, pk): """https://github.com/johnsensible/django-sendfile""" invoice = get_object_or_404(Invoice, pk=pk) check_perm(request.user, invoice.contact) return sendfile( request, invoice.pdf.path, attachment=True, attachment_filename='{}.pdf'.format(invoice.invoice_number) )
def report_invoice_time_analysis_csv(request, pk): invoice = get_object_or_404(Invoice, pk=pk) check_perm(request.user, invoice.contact) response = HttpResponse(content_type='text/csv') file_name = 'invoice_{}_time_analysis.csv'.format(invoice.pk) response['Content-Disposition'] = 'attachment; filename="{}"'.format( file_name) report = ReportInvoiceTimeAnalysisCSV() report.report(invoice, request.user, response) return response
def report_invoice_time_analysis_csv(request, pk): invoice = get_object_or_404(Invoice, pk=pk) check_perm(request.user, invoice.contact) response = HttpResponse(content_type='text/csv') file_name = 'invoice_{}_time_analysis.csv'.format(invoice.pk) response['Content-Disposition'] = 'attachment; filename="{}"'.format( file_name ) report = ReportInvoiceTimeAnalysisCSV() report.report(invoice, request.user, response) return response