Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwood committed Dec 18, 2024
1 parent 4e45a48 commit 2c49697
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 42 deletions.
24 changes: 12 additions & 12 deletions cove/cove_360/templates/cove_360/components/cookie_consent.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
{% if piwik.site_id %}
var siteID = {{piwik.site_id}};
{% endif %}
const _paq = window._paq = window._paq || [];
// {% if piwik.site_id %} // eslint-disable-line
const siteID = Number('{{piwik.site_id}}');
// {% endif %} // eslint-disable-line
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['requireCookieConsent']); // Don't use cookies unless we have consent
_paq.push(['setCookieDomain', '*.threesixtygiving.org']);
_paq.push(['setDownloadExtensions', "json|csv|xlsx"]);
_paq.push(['setDownloadExtensions', 'json|csv|xlsx']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.threesixtygiving.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
if(!siteID) throw new Error("siteID not set");
(function () {
const u = 'https://analytics.threesixtygiving.org/';
_paq.push(['setTrackerUrl', u + 'matomo.php']);
if (!siteID) throw new Error('siteID not set');
_paq.push(['setSiteId', siteID]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
const d = document; const g = d.createElement('script'); const s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript'; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
})();
</script>
<!-- End Matomo Code -->
Expand All @@ -30,7 +30,7 @@
}
}

function noCookieConsent () {
function noCookieConsent () { // eslint-disable-line no-unused-vars
document.cookie = 'noEnhancedAnalytics=1; max-age=2592000; domain=threesixtygiving.org';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,18 @@ <h1 id="report">Report</h1>

<script>
window.addEventListener('load', function () {
const selfPublishEnabled = '{{ data_status.publisher.self_publish.enabled }}';
const dataPassed = '{{ data_status.passed }}';

let publisherValidation, dataValidation;

if ('{{ data_status.publisher.self_publish.enabled }}' === 'True') {
if (selfPublishEnabled === 'True') {
publisherValidation = 'publishing-enabled';
} else {
publisherValidation = 'publishing-disabled';
}

if ('{{ data_status.passed }}' === 'True') {
if (dataPassed === 'True') {
dataValidation = 'data-valid';
} else {
dataValidation = 'data-invalid';
Expand All @@ -111,8 +114,7 @@ <h1 id="report">Report</h1>
const validation = `${publisherValidation}-${dataValidation}`;
const source = '{{ source_url }}';

_paq.push(['trackEvent', 'Status', validation, source]);
_paq.push(['trackPageView']);
_paq.push(['trackEvent', 'Status', validation, source]); // eslint-disable-line no-undef
_paq.push(['trackPageView']); // eslint-disable-line no-undef
});

</script>
37 changes: 16 additions & 21 deletions cove/cove_360/templates/cove_360/data_loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,40 @@ <h2 class="heading-in-panel" >Data processing is in progress</h2>
<div class="spacer-2"></div>

<script>

const pollUrl = "{% url "xhr_results_ready" pk %}";
const resultsUrl = "{% url "results" pk %}";
const pollUrl = '{% url "xhr_results_ready" pk %}';
const resultsUrl = '{% url "results" pk %}';

// Start the results processing if it returns in time
// If it doesn't, it will fail silently and rely on the polling mechanism

(async function(){

try {
const response = await fetch(resultsUrl);
if (response.ok) {
(async function () {
try {
const response = await fetch(resultsUrl);
if (response.ok) {
window.location.href = resultsUrl;
} else {
throw Error(`Server has errored ${response.statusText}`);
}
} catch (error) {
console.error('Error fetching results:', error);
window.location.href = resultsUrl;
} else {
throw Error(`Server has errored ${response.statusText}`);
}
} catch (error) {
console.error("Error fetching results:", error);
window.location.href = resultsUrl;
}

})();


async function updateStatus() {
async function updateStatus () {
try {
const response = await fetch(pollUrl);
const data = response.json();
if (data.done) {
clearInterval(poller);
window.location.href = resultsUrl;
}
} catch {
console.error("Error updating status:", error);
window.location.href = resultsUrl;
} catch (error) {
console.error('Error updating status:', error);
window.location.href = resultsUrl;
}
}

const poller = setInterval(updateStatus, 5000);

</script>
{% endblock %}
4 changes: 2 additions & 2 deletions cove/cove_360/templates/cove_360/publisher_not_found.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h3>Problem submitting your data</h3>
const validation = publisherValidation + '-' + dataValidation;
const source = '{{ source_url }}';

_paq.push(['trackEvent', 'Status', validation, source]);
_paq.push(['trackPageView']);
_paq.push(['trackEvent', 'Status', validation, source]); // eslint-disable-line no-undef
_paq.push(['trackPageView']); // eslint-disable-line no-undef
});
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions cove/cove_360/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
"message": 'Common causes of this error notice are missing or extra digits, typos or incorrect values such as text appearing in this field. UK Company numbers are typically 8 digits, for example <span class="highlight-background-text">09876543</span> or sometimes start with a 2 letter prefix, <span class="highlight-background-text">SC123459</span>. You can check company numbers online at <a target=\"_blank\" href="https://find-and-update.company-information.service.gov.uk/">Companies House</a>. This error may also be triggered by correctly formatted non-UK company numbers, in which case this message can be ignored.',
"type": "RecipientOrgCompanyNumber",
"count": 1,
"category": TestCategories.GRANTS,
"category": TestCategories.ORGANISATIONS,
"percentage": 1/TOTAL_GRANTS
},
["grants/0/recipientOrganization/0/companyNumber"],
Expand Down Expand Up @@ -693,7 +693,7 @@
"message": 'Use an external reference, such as a charity or company number, to identify a funding organisation whenever possible. Some funders do not have an official registration number that can be used. In these cases the funding organisation identifier should reuse the publisher prefix and therefore start with “360G-”. See our <a target=\"_blank\" href="https://standard.threesixtygiving.org/en/latest/technical/identifiers/#organisation-identifier">guidance on organisation identifiers</a> for further help.',
"type": "FundingOrg360GPrefix",
"count": 1,
"category": TestCategories.GRANTS,
"category": TestCategories.ORGANISATIONS,
"percentage": 1/TOTAL_GRANTS,
},
["grants/1/fundingOrganization/0/id"],
Expand Down

0 comments on commit 2c49697

Please sign in to comment.