This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from communitiesuk/FPASF-153-download-report
Send user to find service download page to download the file
- Loading branch information
Showing
9 changed files
with
245 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends "base.html" %} | ||
|
||
{%- from 'govuk_frontend_jinja/components/back-link/macro.html' import govukBackLink -%} | ||
|
||
{% block pageTitle %} | ||
Your link to download data has expired – {{ config['SERVICE_NAME'] }} – GOV.UK | ||
{% endblock pageTitle %} | ||
|
||
{% set mainClasses = "govuk-main-wrapper--l" %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl">Your link to download data has expired</h1> | ||
<p class="govuk-body">Your data download link has expired.</p> | ||
<p class="govuk-body">You can <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.download') }}">create a new data download using new filter options</a>.</p> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl">Your data is ready to be downloaded</h1> | ||
<div class="govuk-inset-text"> | ||
<p>You requested a data download on <span class="govuk-!-font-weight-bold">{{ context.date }}</span>. | ||
<br>File format: <span class="govuk-!-font-weight-bold">{{ context.file_format }}, {{ context.file_size }}</span></p> | ||
</div> | ||
<form id="download-form" method="post" action="{{ url_for('.retrieve_download', filename=context.filename) }}"> | ||
{{ form.csrf_token }} | ||
{{ form.download }} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
from app.main.download_data import get_file_format_from_content_type, get_human_readable_file_size | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"file_extension, expected_file_format", | ||
[ | ||
("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Microsoft Excel spreadsheet"), | ||
("application/json", "JSON file"), | ||
("plain/text", "Unknown file"), | ||
("", "Unknown file"), | ||
], | ||
) | ||
def test_get_file_format_from_content_type(file_extension, expected_file_format): | ||
"""Test get_file_format_from_content_type() function with various file extensions.""" | ||
assert get_file_format_from_content_type(file_extension) == expected_file_format | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"file_size_bytes, expected_file_size_str", | ||
[ | ||
(1024, "1.0 KB"), | ||
(1024 * 20 + 512, "20.5 KB"), | ||
(1024 * 1024, "1.0 MB"), | ||
(1024 * 1024 * 10.67, "10.7 MB"), | ||
(1024 * 1024 * 1024, "1.0 GB"), | ||
(1024 * 1024 * 1024 * 2.58, "2.6 GB"), | ||
], | ||
) | ||
def test_get_human_readable_file_size(file_size_bytes, expected_file_size_str): | ||
"""Test get_human_readable_file_size() function with various file sizes.""" | ||
assert get_human_readable_file_size(file_size_bytes) == expected_file_size_str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters