From 964b1013d94162836e1488777f89867241a6f083 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 21 Nov 2016 15:35:56 -0500 Subject: [PATCH] Make receipt filenames include date information Fixes #1997 --- endpoints/web.py | 8 ++++++-- static/directives/billing-invoices.html | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/endpoints/web.py b/endpoints/web.py index f08efd800..40ad37812 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -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) diff --git a/static/directives/billing-invoices.html b/static/directives/billing-invoices.html index ed9dc5003..f8f33dda7 100644 --- a/static/directives/billing-invoices.html +++ b/static/directives/billing-invoices.html @@ -54,7 +54,7 @@ - +