diff --git a/app/main/views/organizations.py b/app/main/views/organizations.py index 3cbbb0b37..51c8cb3fb 100644 --- a/app/main/views/organizations.py +++ b/app/main/views/organizations.py @@ -76,7 +76,7 @@ def get_organization_message_allowance(org_id): } -def get_services_usage(organization, year): +def get_services_dashboard_data(organization, year): try: dashboard_data = organizations_client.get_organization_dashboard(organization.id, year) services = dashboard_data.get("services", []) @@ -87,7 +87,8 @@ def get_services_usage(organization, year): for service in services: service["id"] = service.get("service_id") service["name"] = service.get("service_name") - service["recent_template"] = service.get("recent_sms_template_name") + service["recent_template"] = service.get("recent_sms_template_name") or "N/A" + service["primary_contact"] = service.get("primary_contact") or "N/A" emails_sent = service.get("emails_sent", 0) sms_sent = service.get("sms_billable_units", 0) @@ -118,7 +119,7 @@ def organization_dashboard(org_id): message_allowance = get_organization_message_allowance(org_id) - services_with_usage = get_services_usage(current_organization, year) + services_with_usage = get_services_dashboard_data(current_organization, year) return render_template( "views/organizations/organization/index.html", diff --git a/app/models/organization.py b/app/models/organization.py index e7eb09f37..33f5f3ec4 100644 --- a/app/models/organization.py +++ b/app/models/organization.py @@ -139,8 +139,8 @@ class Organization(JSONModel, SortByNameMixin): def associate_service(self, service_id): organizations_client.update_service_organization(service_id, self.id) - def services_and_usage(self, financial_year, include_all_services=False): - return organizations_client.get_services_and_usage(self.id, financial_year, include_all_services) + def services_and_usage(self, financial_year): + return organizations_client.get_services_and_usage(self.id, financial_year) class Organizations(SerialisedModelCollection): diff --git a/app/notify_client/organizations_api_client.py b/app/notify_client/organizations_api_client.py index 08b848fc2..e68b23f35 100644 --- a/app/notify_client/organizations_api_client.py +++ b/app/notify_client/organizations_api_client.py @@ -72,10 +72,10 @@ class OrganizationsClient(NotifyAdminAPIClient): def remove_user_from_organization(self, org_id, user_id): return self.delete(f"/organizations/{org_id}/users/{user_id}") - def get_services_and_usage(self, org_id, year, include_all_services=False): + def get_services_and_usage(self, org_id, year): return self.get( url=f"/organizations/{org_id}/services-with-usage", - params={"year": str(year), "include_all_services": str(include_all_services).lower()}, + params={"year": str(year)}, ) def get_organization_message_usage(self, org_id): diff --git a/app/templates/views/organizations/organization/index.html b/app/templates/views/organizations/organization/index.html index 600405b7b..6afc33c4d 100644 --- a/app/templates/views/organizations/organization/index.html +++ b/app/templates/views/organizations/organization/index.html @@ -104,9 +104,9 @@ Live {% endif %} - {{ service.usage|default('N/A') }} - {{ service.primary_contact|default('N/A') }} - {{ service.recent_template|default('N/A') }} + {{ service.usage }} + {{ service.primary_contact }} + {{ service.recent_template }} {% endfor %} {% else %} diff --git a/tests/app/main/views/organizations/test_organizations.py b/tests/app/main/views/organizations/test_organizations.py index ecb4be378..70389b8d6 100644 --- a/tests/app/main/views/organizations/test_organizations.py +++ b/tests/app/main/views/organizations/test_organizations.py @@ -354,7 +354,7 @@ def test_organization_services_shows_live_services_and_usage( client_request.login(active_user_with_permissions) page = client_request.get(".organization_usage", org_id=ORGANISATION_ID) - mock.assert_called_once_with(ORGANISATION_ID, 2020, False) + mock.assert_called_once_with(ORGANISATION_ID, 2020) services = page.select("main h3") usage_rows = page.select("main .grid-col-6") @@ -447,7 +447,7 @@ def test_organization_services_filters_by_financial_year( org_id=ORGANISATION_ID, year=financial_year, ) - mock.assert_called_once_with(ORGANISATION_ID, financial_year, False) + mock.assert_called_once_with(ORGANISATION_ID, financial_year) assert normalize_spaces(page.select_one(".pill").text) == ( "2020 to 2021 fiscal year " "2019 to 2020 fiscal year " @@ -1609,7 +1609,7 @@ def test_organization_dashboard_shows_service_counts( assert "1 Suspended" in normalize_spaces(service_box.text) -def test_organization_dashboard_services_table_shows_usage( +def test_organization_dashboard_services_table( client_request, mock_get_organization, mocker, @@ -1642,6 +1642,7 @@ def test_organization_dashboard_services_table_shows_usage( "sms_remainder": 249500, "sms_cost": 42.75, "recent_sms_template_name": "Welcome SMS", + "primary_contact": None, }, { "service_id": "2", @@ -1653,6 +1654,7 @@ def test_organization_dashboard_services_table_shows_usage( "sms_remainder": 249900, "sms_cost": 0, "recent_sms_template_name": "Reminder SMS", + "primary_contact": None, }, ] },