From 85b3978061fce718f260f8231392fd4bee14ea64 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 2 Jan 2018 14:06:39 +0000 Subject: [PATCH 1/2] Force example CSV to download, not open in browser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We wouldn’t wan’t anyone just seeing the raw CSV data in their browser – it isn’t clear what a user would do with it at that point. And we wouldn’t want it navigating them away from the send page, because this might cause them to lose their place. This commit forces the file to download using the HTML5 `download` attribute: > This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. – https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download --- app/templates/views/send.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/send.html b/app/templates/views/send.html index 0049292f6..3215b4601 100644 --- a/app/templates/views/send.html +++ b/app/templates/views/send.html @@ -40,7 +40,7 @@ {% endcall %}

Your file will populate this template ({{ template.name }})

From a604ed60b675eb69867193f3085cd01aceeaeb4f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 2 Jan 2018 14:38:14 +0000 Subject: [PATCH 2/2] Remove value of download attribute on links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should standardise on rather than everywhere. The value of the download attribute tells the browser what filename to use, but is overridden by the Content-Disposition HTTP header. Since it’s not being used, we should remove it for the sake of disambiguation. --- app/templates/partials/jobs/notifications.html | 2 +- app/templates/views/check/ok.html | 2 +- app/templates/views/dashboard/_inbox_messages.html | 2 +- app/templates/views/notifications/check.html | 2 +- app/templates/views/notifications/notification.html | 2 +- app/templates/views/send.html | 2 +- tests/app/main/views/test_jobs.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 70a086715..5a9c3ffd7 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -31,7 +31,7 @@

{% elif notifications %}

- Download this report + Download this report{{ time_left }}

diff --git a/app/templates/views/check/ok.html b/app/templates/views/check/ok.html index 792f016d1..85f79b97b 100644 --- a/app/templates/views/check/ok.html +++ b/app/templates/views/check/ok.html @@ -39,7 +39,7 @@ {% if template.template_type != 'letter' or not request.args.from_test %} {% else %} - Download as a printable PDF + Download as a printable PDF {% endif %} Back diff --git a/app/templates/views/dashboard/_inbox_messages.html b/app/templates/views/dashboard/_inbox_messages.html index b46b16a8c..bba1e741d 100644 --- a/app/templates/views/dashboard/_inbox_messages.html +++ b/app/templates/views/dashboard/_inbox_messages.html @@ -4,7 +4,7 @@
{% if messages %}

- Download these messages + Download these messages

{% endif %} {% call(item, row_number) list_table( diff --git a/app/templates/views/notifications/check.html b/app/templates/views/notifications/check.html index 19c5d34e4..a58eee691 100644 --- a/app/templates/views/notifications/check.html +++ b/app/templates/views/notifications/check.html @@ -53,7 +53,7 @@ {% if template.template_type != 'letter' or not request.args.from_test %} {% else %} - Download as a printable PDF + Download as a printable PDF {% endif %} {% endif %} Back diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index f0ef58dba..f50a3c634 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -35,7 +35,7 @@ Estimated delivery date: {{ estimated_letter_delivery_date|string|format_date_short }}

- Download as a PDF + Download as a PDF

{% endif %} diff --git a/app/templates/views/send.html b/app/templates/views/send.html index 3215b4601..0ab3345ca 100644 --- a/app/templates/views/send.html +++ b/app/templates/views/send.html @@ -40,7 +40,7 @@ {% endcall %}

Your file will populate this template ({{ template.name }})

diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 43a9c784e..2b812ca3f 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -97,7 +97,7 @@ def test_should_show_page_for_one_job( job_id=fake_uuid, status=status_argument, ) - csv_link = page.find('a', {'download': 'download'}) + csv_link = page.select_one('a[download]') assert csv_link['href'] == url_for( 'main.view_job_csv', service_id=service_one['id'],