Merge pull request #2154 from coreos-inc/receipt-filename
Make receipt filenames include date information
This commit is contained in:
commit
1529ed2086
2 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from cachetools import lru_cache
|
||||
from flask import (abort, redirect, request, url_for, make_response, Response, render_template,
|
||||
|
@ -353,10 +353,14 @@ def receipt():
|
|||
abort(404)
|
||||
return
|
||||
|
||||
def format_date(timestamp):
|
||||
return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d')
|
||||
|
||||
file_data = renderInvoiceToPdf(invoice, user_or_org)
|
||||
receipt_filename = 'quay-receipt-%s.pdf' % (format_date(invoice.date))
|
||||
return Response(file_data,
|
||||
mimetype="application/pdf",
|
||||
headers={"Content-Disposition": "attachment;filename=receipt.pdf"})
|
||||
headers={"Content-Disposition": "attachment;filename=" + receipt_filename})
|
||||
abort(404)
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
</span>
|
||||
</td>
|
||||
<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>
|
||||
</a>
|
||||
</td>
|
||||
|
|
Reference in a new issue