mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Add usage stats to organisation page.
This commit is contained in:
@@ -125,8 +125,10 @@ def add_organisation_from_nhs_local_service(service_id):
|
||||
@main.route("/organisations/<uuid:org_id>", methods=['GET'])
|
||||
@user_has_permissions()
|
||||
def organisation_dashboard(org_id):
|
||||
services = current_organisation.services_and_usage()
|
||||
return render_template(
|
||||
'views/organisations/organisation/index.html',
|
||||
services=services
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from app.models import JSONModel, ModelList
|
||||
from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.letter_branding_client import letter_branding_client
|
||||
from app.notify_client.organisations_api_client import organisations_client
|
||||
from app.utils import get_current_financial_year
|
||||
|
||||
|
||||
class Organisation(JSONModel):
|
||||
@@ -198,6 +199,9 @@ class Organisation(JSONModel):
|
||||
self.id
|
||||
)
|
||||
|
||||
def services_and_usage(self):
|
||||
return organisations_client.get_services_and_usage(self.id, get_current_financial_year())
|
||||
|
||||
|
||||
class Organisations(ModelList):
|
||||
client_method = organisations_client.get_organisations
|
||||
|
||||
@@ -87,5 +87,11 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
params={"org_id": org_id, "name": name}
|
||||
)["result"]
|
||||
|
||||
def get_services_and_usage(self, org_id, year):
|
||||
return self.get(
|
||||
url=f"/organisations/{org_id}/services-with-usage",
|
||||
params={"year": str(year)}
|
||||
)
|
||||
|
||||
|
||||
organisations_client = OrganisationsClient()
|
||||
|
||||
@@ -9,11 +9,17 @@
|
||||
<h1 class="heading-medium">
|
||||
Usage
|
||||
</h1>
|
||||
|
||||
<ul>
|
||||
{% for service in current_org.live_services %}
|
||||
{% for service in services['services'] %}
|
||||
<li class="browse-list-item">
|
||||
<a href="{{ url_for('main.usage', service_id=service.id) }}" class="govuk-link govuk-link--no-visited-state browse-list-link">{{ service['name'] }}</a>
|
||||
<a href="{{ url_for('main.usage', service_id=service.service_id) }}" class="govuk-link govuk-link--no-visited-state browse-list-link">{{ service.service_name }}</a>
|
||||
</li>
|
||||
<div class="grid-row">
|
||||
<div class="column-one-third">{{ service.emails_sent|format_thousands }} emails sent</div>
|
||||
<div class="column-one-third">{{ "£{:,.2f}".format(service.sms_cost) }} spent on text messages</div>
|
||||
<div class="column-one-third">{{ "£{:,.2f}".format(service.letter_cost) }} spent on letters</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user