Skip to content

Commit 3eee83f

Browse files
committed
wip
1 parent f73bed3 commit 3eee83f

File tree

5 files changed

+100
-46
lines changed

5 files changed

+100
-46
lines changed

cove/cove_360/templates/cove_360/components/explore/summary.html

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,47 @@ <h3 id="conversion-title">
234234

235235
{% cove_modal_list className="unique-ids" modalTitle="Unique IDs" itemList=grants_aggregates.unique_ids %}
236236
{% cove_modal_list className="distinct-funding-org-identifier" modalTitle="Funder Organisation IDs" itemList=grants_aggregates.distinct_funding_org_identifier %}
237-
{% cove_modal_list className="distinct-recipient-org-identifier" modalTitle="Recipient Organisation IDs" itemList=grants_aggregates.distinct_recipient_org_identifier %}
237+
{% cove_modal_list className="distinct-recipient-org-identifier" modalTitle="Recipient Organisation IDs" itemList=grants_aggregates.distinct_recipient_org_identifier %}
238+
239+
240+
<h3 class="panel-title panel-title-explore">
241+
{% trans "Download data and share these results" %}
242+
</h3>
243+
<h4>Share</h4>
244+
<p>{% trans "You can share these test results with others by using the following url:" %}</p>
245+
<p><a href="{{current_url}}"> {{ current_url }}</a>
246+
<button class="button button--small margin-left:1" onclick="navigator.clipboard.writeText('{{current_url}}'); this.innerHTML = 'Copied!';">Copy Link to Clipboard</button>
247+
</p>
248+
<p>{% trans "If your data is not suitable for sharing publicly, then you should treat this url with care. Only share it with people who have permission to access the data." %}</p>
249+
<p>{% trans "After 7 days, the link will expire and the data will be deleted from our servers - so the results will no longer be available. You can revisit these results until then." %}</p>
250+
<h4><span class="glyphicon glyphicon-download-alt"></span> Download</h4>
251+
<p>{% trans "This application converts data in Excel and CSV format into JSON format, allowing you download the converted version." %}</p>
252+
<p>{% trans "If your file is originally in JSON format select ‘Convert to Spreadsheet’ in the summary section to create an Excel version of the file." %}</p>
253+
{% if not conversion_error and conversion != 'flattenable' %}
254+
<p>{% trans "We provide the following formats to download:" %}</p>
255+
<ul class="left-space">
256+
{% if conversion == 'unflatten' %}
257+
<li>
258+
<a href="{{converted_url}}">{{JSON}} ({% trans converted %})</a> {{converted_file_size|filesizeformat}}
259+
</li>
260+
{% elif conversion == 'flatten' %}
261+
<li>
262+
<a href="{{converted_url}}-titles.xlsx">{{xlsx}} ({% trans converted %})</a> {{converted_file_size_titles|filesizeformat}}
263+
</li>
264+
<li class="list-unstyled">
265+
<sub>{% trans "You can also download an" %}<a href="{{converted_url}}.xlsx"> {% trans "Excel Spreadsheet (.xlsx) with JSON field names" %}</a> {% trans "instead of titles as column headers" %} ({{converted_file_size|filesizeformat}})</sub>
266+
</li>
267+
{% endif %}
268+
</ul>
269+
{% else %}
270+
<p>(No downloads available as the conversion hasn't happened, or has errored).</p>
271+
{% endif %}
272+
{% if user.is_authenticated %}
273+
<h3 class="box__heading">Original file download for admin users</h2>
274+
<p>Warning, this is the original file uploaded. Do not download if you don't trust whoever sent you a link to this page, it could contain a virus. Note that this box and this download link are only visible to admin users, not others you share this page with.</p>
275+
<ul class="left-space">
276+
<li>
277+
<a href="{{original_file.url}}">{% trans "Original file" %} ({{file_type}})</a> {{original_file.size|filesizeformat}}
278+
</li>
279+
</ul>
280+
{% endif %}

cove/cove_360/templates/cove_360/components/explore_checking.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{% load i18n %} {% load humanize %} {% load cove_tags %}
22

3+
{% trans 'Converted from Original' as converted %}
4+
{% trans 'Original' as original %}
5+
{% trans 'Excel Spreadsheet (.xlsx)' as xlsx %}
6+
{% trans 'OpenDocument Spreadsheet (.ods)' as ods %}
7+
{% trans 'CSV Spreadsheet (.csv)' as csv %}
8+
{% trans 'Excel Spreadsheet (.xlsx) with titles' as xlsx_titles %}
9+
{% trans 'OpenDocument Spreadsheet (.ods) with titles' as ods_titles %}
10+
{# Translators: JSON probably does not need a transalation: http://www.json.org/ #}
11+
{% trans 'JSON' as JSON %}
12+
{% trans 'XML' as XML %}
13+
314
<div
415
class="margin-top:1 margin-bottom:2"
516
style="display: flex; flex-direction: row; justify-content: end"
@@ -112,15 +123,5 @@ <h2 class="base-card__title">{{usefulness_checks_count }}</h2>
112123
<div class="spacer-4"></div>
113124

114125
<script>
115-
(function(){
116-
/* If "?open-all=true" is passed show all tabs on the page at once */
117-
const params = new URLSearchParams(window.location.search);
118-
119-
if (params.get("open-all")){
120-
for (const tab of document.getElementsByClassName("tab-content")){
121-
tab.removeAttribute("style");
122-
}
123-
}
124126

125-
})();
126127
</script>

cove/cove_360/templates/cove_360/components/explore_publishing.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{% load i18n %}
22

3+
{% trans 'Converted from Original' as converted %}
4+
{% trans 'Original' as original %}
5+
{% trans 'Excel Spreadsheet (.xlsx)' as xlsx %}
6+
{% trans 'OpenDocument Spreadsheet (.ods)' as ods %}
7+
{% trans 'CSV Spreadsheet (.csv)' as csv %}
8+
{% trans 'Excel Spreadsheet (.xlsx) with titles' as xlsx_titles %}
9+
{% trans 'OpenDocument Spreadsheet (.ods) with titles' as ods_titles %}
10+
{# Translators: JSON probably does not need a transalation: http://www.json.org/ #}
11+
{% trans 'JSON' as JSON %}
12+
{% trans 'XML' as XML %}
13+
314
<h3>{% trans "Submit your data" %}</h3>
415

516
<div class="base-card base-card--red margin-bottom:2">

cove/cove_360/templates/cove_360/data_loading.html

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,36 @@ <h2 class="heading-in-panel" >Data processing is in progress</h2>
2727

2828
// Start the results processing if it returns in time
2929
// If it doesn't, it will fail silently and rely on the polling mechanism
30-
fetch(resultsUrl)
31-
.then((response) => {
32-
if (response.ok) {
30+
31+
(async function(){
32+
33+
try {
34+
const response = await fetch(resultsUrl);
35+
if (response.ok) {
36+
window.location.href = resultsUrl;
37+
} else {
38+
throw Error(`Server has errored ${response.statusText}`);
39+
}
40+
} catch (error) {
41+
console.error("Error fetching results:", error);
42+
window.location.href = resultsUrl;
43+
}
44+
45+
})();
46+
47+
48+
async function updateStatus() {
49+
try {
50+
const response = await fetch(pollUrl);
51+
const data = response.json();
52+
if (data.done) {
53+
clearInterval(poller);
3354
window.location.href = resultsUrl;
3455
}
35-
})
36-
.catch((error) => {
37-
console.error("Error fetching results:", error);
38-
});
39-
40-
function updateStatus() {
41-
fetch(pollUrl)
42-
.then((response) => response.json())
43-
.then((data) => {
44-
if (data.done) {
45-
clearInterval(poller);
46-
window.location.href = resultsUrl;
47-
}
48-
console.log(data);
49-
})
50-
.catch((error) => {
56+
} catch {
5157
console.error("Error updating status:", error);
5258
window.location.href = resultsUrl;
53-
});
59+
}
5460
}
5561

5662
const poller = setInterval(updateStatus, 5000);

cove/cove_360/tests_functional.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,34 @@ def server_url(request, live_server):
7171
'Unique grant identifiers: 2',
7272
'Unique funder organisation identifiers: 1',
7373
'360G-fundingproviders-000002/X/00/X'], True),
74-
('fundingproviders-grants_broken_grants.json', ['data does not use the 360Giving Data Standard correctly (15 Errors)',
75-
'Check your data 4 Grants',
74+
('fundingproviders-grants_broken_grants.json', ['data does not use the 360Giving Data Standard correctly',
75+
'15 Errors',
7676
'Unique funder organisation identifiers: 2',
7777
'Unique recipient organisation identifiers: 2',
7878
'360G-fundingproviders-000002/X/00/X'], True),
79-
('fundingproviders-grants_2_grants.xlsx', ['Data about 1 funder',
79+
('fundingproviders-grants_2_grants.xlsx', ['1 funding organisation',
8080
'There are 2 grants to 1 recipient organisation and 0 to recipient individuals',
8181
'The grants were awarded in GBP with a total value of £331,495',
8282
# check that there's no errors after the heading
8383
'Data conversion successful\nBefore checking',
84-
'data does not use the 360Giving Data Standard correctly (7 Errors)',
84+
'data does not use the 360Giving Data Standard correctly',
85+
'7 Errors',
8586
'description is missing but required',
8687
'Sheet: grants Row: 2',
87-
'Check your data 2 Grants',
8888
'Unique funder organisation identifiers: 1',
8989
'Unique recipient organisation identifiers: 1',
9090
'360G-fundingproviders-000002/X/00/X'], True),
9191
# Test conversion warnings are shown
9292
('tenders_releases_2_releases.xlsx', ['Data conversion unsuccessful - 5 Errors have been found',
93-
'data does not use the 360Giving Data Standard correctly (76 Errors)',
93+
'data does not use the 360Giving Data Standard correctly',
94+
'76 Errors',
9495
'You may have a duplicate Identifier: We couldn\'t merge these rows with the id "1": field "ocid" in sheet "items": one cell has the value: "PW-14-00627094", the other cell has the value: "PW-14-00629344"'
9596
], True),
9697
# Test that titles that aren't in the rollup are converted correctly
9798
# (See @check_url_input_result_page).
9899
('fundingproviders-grants_2_grants_titleswithoutrollup.xlsx', [], True),
99100
# Test a 360 csv in cp1252 encoding
100-
('fundingproviders-grants_2_grants_cp1252.csv', ['Data about 1 funder',
101+
('fundingproviders-grants_2_grants_cp1252.csv', ['1 funding organisation',
101102
'There are 2 grants to 1 recipient organisation and 0 to recipient individuals',
102103
'The grants were awarded in GBP with a total value of £331,495',
103104
'This file is not \'utf-8\' encoded (it is cp1252 encoded)'], True),
@@ -214,8 +215,6 @@ def test_explore_360_url_input(server_url, browser, httpserver, source_filename,
214215
browser.find_element_by_class_name("cookie-consent-no").click()
215216

216217
# Do the assertions
217-
218-
a = input()
219218
check_url_input_result_page(server_url, browser, httpserver, source_filename, expected_text, conversion_successful, authed)
220219

221220

@@ -232,9 +231,6 @@ def check_url_input_result_page(server_url, browser, httpserver, source_filename
232231
if source_filename == 'validation_errors-3.json':
233232
assert 'UNSAFE' not in body_text
234233

235-
assert 'Data Quality Tool' in browser.find_element_by_class_name('title360').text
236-
assert '360Giving' in browser.find_element_by_tag_name('body').text
237-
238234
if conversion_successful:
239235
if source_filename.endswith('.json'):
240236
if authed:
@@ -260,9 +256,6 @@ def check_url_input_result_page(server_url, browser, httpserver, source_filename
260256
converted_file = browser.find_element_by_link_text("JSON (Converted from Original)").get_attribute("href")
261257
assert "unflattened.json" in browser.find_element_by_link_text("JSON (Converted from Original)").get_attribute("href")
262258

263-
# Test for Load New File button
264-
assert 'Load New File' in body_text
265-
266259
if authed:
267260
assert 'Note that this box and this download link are only visible to admin users' in body_text
268261

0 commit comments

Comments
 (0)