Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwood committed Dec 16, 2024
1 parent c57d3db commit 13576d6
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 112 deletions.
27 changes: 27 additions & 0 deletions cove/cove_360/fixtures/additional_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"grants": [
{
"id": "360G-sampletrust-105177/Z/14/Z",
"awardDate": "2024-12-30",
"amountAwarded": 10,
"url": "http://example.com",
"title": "test",
"currency": "GBP",
"description": "test",
"AdditionalField": "2",
"CheckMicOne": "two",
"recipientOrganization": [
{
"id": "GB-323242-test",
"name": "Example Project Limited"
}
],
"fundingOrganization": [
{
"id": "GB-323242-test",
"name": "Example Project Limited"
}
]
}
]
}
1 change: 0 additions & 1 deletion cove/cove_360/fixtures/duration_usefulness.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"name": "Example Project Limited"
}
],
"plannedDates": [],
"fundingOrganization": [
{
"id": "GB-323242-test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

<h2>Data Accuracy</h2>

{% if validation_errors or additional_closed_codelist_values %}
<p>The data provided did not pass <a href="#validity">validation</a> therefore the accuracy of the data could not be determined.</a>
{% else %}

{% if quality_accuracy_checks_passed %}
<h3>What is working well</h3>
Expand Down Expand Up @@ -85,4 +88,5 @@ <h4>{{category}}</h4>
{% endwith %}
{% endfor %}

{% endif %} {# Quality accuracy errored #}
{% endif %} {# Quality accuracy errored #}
{% endif %} {# validation failed #}
208 changes: 124 additions & 84 deletions cove/cove_360/templates/cove_360/components/explore/summary.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

<h2>Usefulness Opportunities</h2>

{% if validation_errors or additional_closed_codelist_values %}
<p>The data provided did not pass <a href="#validity">validation</a> therefore the usefulness of the data could not be determined.</a>
{% else %}

{% if usefulness_checks_passed %}
<h3>What is working well</h3>
<p><i class="material-icons table--true">check</i>Congratulations, <strong>{{usefulness_checks_passed|length}}</strong> of our usefulness checks passed.</p>
Expand Down Expand Up @@ -99,3 +103,4 @@ <h4>{{category}}</h4>
{% else %}
<p>No usefulness opportunities detected.</p>
{% endif %}
{% endif %} {# validation failed #}
22 changes: 17 additions & 5 deletions cove/cove_360/templates/cove_360/components/explore_checking.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ <h2 class="base-card__title">
<div class="grid__1">
<div class="base-card base-card--yellow">
<div class="base-card__content">
<h2 class="base-card__title">{{quality_accuracy_checks_count}}</h2>
<h2 class="base-card__title">
{% if validation_and_closed_codelist_errors_count %}
0
{% else %}
{{quality_accuracy_checks_count}}
{% endif %}
</h2>
<p class="base-card__text">Potential accuracy issue</p>
</div>
</div>
Expand All @@ -49,7 +55,13 @@ <h2 class="base-card__title">{{quality_accuracy_checks_count}}</h2>
<div class="grid__1">
<div class="base-card base-card--teal">
<div class="base-card__content">
<h2 class="base-card__title">{{usefulness_checks_count }}</h2>
<h2 class="base-card__title">
{% if validation_and_closed_codelist_errors_count %}
0
{% else %}
{{usefulness_checks_count }}
{% endif %}
</h2>
<p class="base-card__text">Usefulness opportunities</p>
</div>
</div>
Expand Down Expand Up @@ -86,7 +98,7 @@ <h2 class="base-card__title">{{usefulness_checks_count }}</h2>
href="#accuracy"
id="accuracy-tab-link"
>
{% trans "Accuracy" %} ({{quality_accuracy_checks_count}})
{% trans "Accuracy" %} ({% if validation_and_closed_codelist_errors_count %}0{% else %}{{quality_accuracy_checks_count}}{% endif %})
</a>
</span>

Expand All @@ -96,8 +108,8 @@ <h2 class="base-card__title">{{usefulness_checks_count }}</h2>
href="#usefulness"
id="usefulness-tab-link"
>
{% trans "Usefulness" %} ({{usefulness_checks_count}})
</a>
{% trans "Usefulness" %} ({% if validation_and_closed_codelist_errors_count %}0{% else %}{{usefulness_checks_count }}{% endif %})
</a>
</span>
</div>

Expand Down
15 changes: 3 additions & 12 deletions cove/cove_360/templates/cove_360/error.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
{% extends request.current_app_base_template %}
{% load i18n %}
{% block content %}
{# fixme this template isn't getting used #}
<h2>{{ sub_title }}</h2>

<div class="panel panel-warning">
<div class="panel-heading">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{{ sub_title }}
</div>
<div class="panel-body">
{{ msg | linebreaks }}

{% include 'error_extra.html' %}
</div>
</div>

<div class="success-button">
<a class="btn btn-success" href="{% if link_args %}{% url link link_args %}{% else %}{% url link %}{% endif %}" role="button">{{ link_text }}</a>
</div>

<a class="button" href="{% if link_args %}{% url link link_args %}{% else %}{% url link %}{% endif %}" role="button">{{ link_text }}</a>


{% endblock %}
Expand Down
8 changes: 4 additions & 4 deletions cove/cove_360/tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def mockflatten(input_name, output_name, *args, **kwargs):

warning_heading = "Data conversion unsuccessful - 1 Error has been found"

conversion_title = browser.find_element(By.ID, "conversion-title")
conversion_title = browser.find_element(By.ID, "conversion-errors")
conversion_title_text = conversion_title.text

if iserror:
Expand Down Expand Up @@ -541,11 +541,11 @@ def test_oneof_validation(server_url, browser, httpserver):
("duration_usefulness.json", [
"1 grant does not contain plannedDates/0/duration or (plannedDates/startDate and plannedDates/endDate)",
], []),
("duration_usefulness.json", [
"1 grant does not contain plannedDates/0/duration or (plannedDates/startDate and plannedDates/endDate)",
("additional_fields.json", [
"Additional fields which do not use 360Giving Data Standard titles were found in your data.",
], []),
("multiple_fundiner_names_org_ids.json", [
"added an additional name for an existing Funding Org"
"introduced an additional name for an existing Funding Org"
], []),
])
def test_quality_checks(server_url, browser, httpserver, source_filename, expected_texts, unexpected_texts):
Expand Down
13 changes: 8 additions & 5 deletions lib360dataquality/cove/threesixtygiving.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ class MultiFundingOrgIdsForName(AdditionalTest):
"""Check for Funding org ids with multiple names."""

check_text = {
"heading": mark_safe("added an additional name for an existing Funding Org"),
"heading": mark_safe("introduced an additional name for an existing Funding Org"),
"message": RangeDict(),
}
check_text["message"][(0, 100)] = mark_safe(
Expand Down Expand Up @@ -1894,10 +1894,13 @@ def create_grant_dates_dict(grant):
grant_dates = {}

award_date = grant.grant.get("awardDate")
planned_start_date = grant.grant.get("plannedDates", [{}])[0].get("startDate")
planned_end_date = grant.grant.get("plannedDates", [{}])[0].get("endDate")
actual_start_date = grant.grant.get("actualDates", [{}])[0].get("startDate")
actual_end_date = grant.grant.get("actualDates", [{}])[0].get("endDate")
try:
planned_start_date = grant.grant.get("plannedDates", [{}])[0].get("startDate")
planned_end_date = grant.grant.get("plannedDates", [{}])[0].get("endDate")
actual_start_date = grant.grant.get("actualDates", [{}])[0].get("startDate")
actual_end_date = grant.grant.get("actualDates", [{}])[0].get("endDate")
except IndexError:
return {}

for date_type, input_date in [
["award_date", award_date],
Expand Down

0 comments on commit 13576d6

Please sign in to comment.