mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Merge pull request #3165 from alphagov/letters-always-on-usage
Always show letters on the dashboard and usage page
This commit is contained in:
@@ -98,6 +98,20 @@
|
||||
|
||||
}
|
||||
|
||||
.usage-table {
|
||||
|
||||
.table-field-heading-first {
|
||||
width: 35%; // 33.33% + fudge
|
||||
}
|
||||
|
||||
.table-row {
|
||||
th {
|
||||
width: 17.5% // 16.67% + fudge
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%table-field,
|
||||
.table-field {
|
||||
|
||||
|
||||
@@ -133,11 +133,8 @@ def usage(service_id):
|
||||
units = billing_api_client.get_billable_units(service_id, year)
|
||||
yearly_usage = billing_api_client.get_service_usage(service_id, year)
|
||||
|
||||
usage_template = 'views/usage.html'
|
||||
if current_service.has_permission('letter'):
|
||||
usage_template = 'views/usage-with-letters.html'
|
||||
return render_template(
|
||||
usage_template,
|
||||
'views/usage.html',
|
||||
months=list(get_free_paid_breakdown_for_billable_units(
|
||||
year,
|
||||
free_sms_allowance,
|
||||
@@ -293,11 +290,8 @@ def get_dashboard_partials(service_id):
|
||||
]
|
||||
|
||||
stats = aggregate_notifications_stats(all_statistics)
|
||||
column_width, max_notifiction_count = get_column_properties(
|
||||
number_of_columns=(
|
||||
3 if current_service.has_permission('letter') else 2
|
||||
)
|
||||
)
|
||||
column_width, max_notifiction_count = get_column_properties(3)
|
||||
|
||||
dashboard_totals = get_dashboard_totals(stats),
|
||||
highest_notification_count = max(
|
||||
sum(
|
||||
|
||||
@@ -27,19 +27,17 @@
|
||||
smaller=smaller_font_size
|
||||
) }}
|
||||
</div>
|
||||
{% if current_service.has_permission('letter') %}
|
||||
<div id="total-letters" class="{{column_width}}">
|
||||
{{ big_number_with_status(
|
||||
statistics['letter']['requested'],
|
||||
message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'),
|
||||
statistics['letter']['failed'],
|
||||
statistics['letter']['failed_percentage'],
|
||||
statistics['letter']['show_warning'],
|
||||
failure_link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='failed'),
|
||||
link=url_for(".view_notifications", service_id=service_id, message_type='letter', status=''),
|
||||
smaller=smaller_font_size
|
||||
) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="total-letters" class="{{column_width}}">
|
||||
{{ big_number_with_status(
|
||||
statistics['letter']['requested'],
|
||||
message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'),
|
||||
statistics['letter']['failed'],
|
||||
statistics['letter']['failed_percentage'],
|
||||
statistics['letter']['show_warning'],
|
||||
failure_link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='failed'),
|
||||
link=url_for(".view_notifications", service_id=service_id, message_type='letter', status=''),
|
||||
smaller=smaller_font_size
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
{% from "components/big-number.html" import big_number %}
|
||||
{% from "components/message-count-label.html" import message_count_label %}
|
||||
{% from "components/table.html" import list_table, field, hidden_field_heading, row_heading, text_field %}
|
||||
{% from "components/pill.html" import pill %}
|
||||
|
||||
{% extends "withnav_template.html" %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Usage
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<h1 class='heading-medium'>Usage</h1>
|
||||
|
||||
<div class="bottom-gutter">
|
||||
{{ pill(years, selected_year, big_number_args={'smallest': True}) }}
|
||||
</div>
|
||||
<div id='pill-selected-item'>
|
||||
<div class='grid-row'>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Emails</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(emails_sent, 'sent', smaller=True) }}
|
||||
{{ big_number("Unlimited", 'free allowance', smaller=True) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Text messages</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(sms_sent, 'sent', smaller=True) }}
|
||||
{{ big_number(sms_free_allowance, 'free allowance', smaller=True) }}
|
||||
{{ big_number(sms_allowance_remaining, 'free allowance remaining', smaller=True) }}
|
||||
{% if sms_chargeable %}
|
||||
{{ big_number(
|
||||
sms_chargeable,
|
||||
'at {:.2f} pence per message'.format(sms_rate * 100),
|
||||
smaller=True
|
||||
) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Letters</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(letter_sent, 'sent', smaller=True) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='grid-row'>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(
|
||||
(sms_chargeable * sms_rate),
|
||||
'spent',
|
||||
currency="£",
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(
|
||||
letter_cost,
|
||||
'spent',
|
||||
currency="£",
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if months %}
|
||||
<div class="dashboard-table body-copy-table">
|
||||
{% call(month, row_index) list_table(
|
||||
months,
|
||||
caption="Total spend",
|
||||
caption_visible=False,
|
||||
empty_message='',
|
||||
field_headings=[
|
||||
'By month',
|
||||
hidden_field_heading('Cost'),
|
||||
],
|
||||
field_headings_visible=True
|
||||
) %}
|
||||
{% call row_heading() %}
|
||||
{{ month.name }}
|
||||
{% endcall %}
|
||||
{% call field(align='left') %}
|
||||
{{ big_number(
|
||||
(sms_rate * month.paid) + month.letter_total,
|
||||
currency="£",
|
||||
smallest=True
|
||||
) }}
|
||||
<ul>
|
||||
{% if month.free %}
|
||||
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free {{ message_count_label(month.free, 'sms', '') }}</li>
|
||||
{% endif %}
|
||||
{% if month.paid %}
|
||||
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} {{ message_count_label(month.paid, 'sms', '') }}at
|
||||
{{- ' {:.2f}p'.format(sms_rate * 100) }}</li>
|
||||
{% endif %}
|
||||
{% for letter in month.letters%}
|
||||
{% if letter[0] %}
|
||||
<li class="tabular-numbers">{{ "{:,} {}".format(letter[0], letter[3])}} class {{ message_count_label(letter[0], 'letter', '') }}at
|
||||
{{ '{:.0f}p'.format(letter[1] * 100) }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if not (month.free or month.paid or month.letters) %}
|
||||
<li aria-hidden="true">–</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-half">
|
||||
<p class="align-with-heading-copy">
|
||||
Financial year ends 31 March.
|
||||
</p>
|
||||
</div>
|
||||
<div class="column-half">
|
||||
<p class="align-with-heading-copy">
|
||||
What counts as 1 text message?<br />
|
||||
See <a href="{{ url_for('.pricing') }}">pricing</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -18,14 +18,14 @@
|
||||
</div>
|
||||
<div id='pill-selected-item'>
|
||||
<div class='grid-row'>
|
||||
<div class='column-half'>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Emails</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(emails_sent, 'sent', smaller=True) }}
|
||||
{{ big_number("Unlimited", 'free allowance', smaller=True) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-half'>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Text messages</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(sms_sent, 'sent', smaller=True) }}
|
||||
@@ -40,15 +40,21 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<h2 class='heading-small'>Letters</h2>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(letter_sent, 'sent', smaller=True) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='grid-row'>
|
||||
<div class='column-half'>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-half'>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(
|
||||
(sms_chargeable * sms_rate),
|
||||
@@ -58,10 +64,21 @@
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class='column-one-third'>
|
||||
<div class="keyline-block">
|
||||
{{ big_number(
|
||||
letter_cost,
|
||||
'spent',
|
||||
currency="£",
|
||||
smaller=True
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if months %}
|
||||
<div class="dashboard-table body-copy-table">
|
||||
<div class="dashboard-table usage-table body-copy-table">
|
||||
{% call(month, row_index) list_table(
|
||||
months,
|
||||
caption="Total spend",
|
||||
@@ -78,7 +95,7 @@
|
||||
{% endcall %}
|
||||
{% call field(align='left') %}
|
||||
{{ big_number(
|
||||
sms_rate * month.paid,
|
||||
(sms_rate * month.paid) + month.letter_total,
|
||||
currency="£",
|
||||
smallest=True
|
||||
) }}
|
||||
@@ -87,10 +104,16 @@
|
||||
<li class="tabular-numbers">{{ "{:,}".format(month.free) }} free {{ message_count_label(month.free, 'sms', '') }}</li>
|
||||
{% endif %}
|
||||
{% if month.paid %}
|
||||
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} {{ message_count_label(month.free, 'sms', '') }}at
|
||||
<li class="tabular-numbers">{{ "{:,}".format(month.paid) }} {{ message_count_label(month.paid, 'sms', '') }}at
|
||||
{{- ' {:.2f}p'.format(sms_rate * 100) }}</li>
|
||||
{% endif %}
|
||||
{% if not (month.free or month.paid) %}
|
||||
{% for letter in month.letters%}
|
||||
{% if letter[0] %}
|
||||
<li class="tabular-numbers">{{ "{:,} {}".format(letter[0], letter[3])}} class {{ message_count_label(letter[0], 'letter', '') }}at
|
||||
{{ '{:.0f}p'.format(letter[1] * 100) }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if not (month.free or month.paid or month.letters) %}
|
||||
<li aria-hidden="true">–</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
@@ -101,12 +124,12 @@
|
||||
</div>
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-half">
|
||||
<div class="column-one-third">
|
||||
<p class="align-with-heading-copy">
|
||||
Financial year ends 31 March.
|
||||
Financial year ends 31 March
|
||||
</p>
|
||||
</div>
|
||||
<div class="column-half">
|
||||
<div class="column-two-thirds">
|
||||
<p class="align-with-heading-copy">
|
||||
What counts as 1 text message?<br />
|
||||
See <a href="{{ url_for('.pricing') }}">pricing</a>.
|
||||
|
||||
Reference in New Issue
Block a user