parent
498d7fc15e
commit
964b1013d9
2 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta, datetime
|
||||||
|
|
||||||
from cachetools import lru_cache
|
from cachetools import lru_cache
|
||||||
from flask import (abort, redirect, request, url_for, make_response, Response, render_template,
|
from flask import (abort, redirect, request, url_for, make_response, Response, render_template,
|
||||||
|
@ -353,10 +353,14 @@ def receipt():
|
||||||
abort(404)
|
abort(404)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def format_date(timestamp):
|
||||||
|
return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d')
|
||||||
|
|
||||||
file_data = renderInvoiceToPdf(invoice, user_or_org)
|
file_data = renderInvoiceToPdf(invoice, user_or_org)
|
||||||
|
receipt_filename = 'quay-receipt-%s.pdf' % (format_date(invoice.date))
|
||||||
return Response(file_data,
|
return Response(file_data,
|
||||||
mimetype="application/pdf",
|
mimetype="application/pdf",
|
||||||
headers={"Content-Disposition": "attachment;filename=receipt.pdf"})
|
headers={"Content-Disposition": "attachment;filename=" + receipt_filename})
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="options-col">
|
<td class="options-col">
|
||||||
<a ng-show="invoice.paid" href="/receipt?id={{ invoice.id }}" download="receipt.pdf" target="_new">
|
<a ng-show="invoice.paid" href="/receipt?id={{ invoice.id }}" target="_new" download>
|
||||||
<i class="fa fa-download" data-title="Download Receipt" bs-tooltip="tooltip.title"></i>
|
<i class="fa fa-download" data-title="Download Receipt" bs-tooltip="tooltip.title"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
Reference in a new issue