Always use smaller font size for totals

This means the font size matches the counts on the usage section, and on
the new received text messages banner.
This commit is contained in:
Chris Hill-Scott
2020-02-12 11:12:18 +00:00
parent b65b417a08
commit 42373e3615
4 changed files with 17 additions and 38 deletions

View File

@@ -280,15 +280,8 @@ def get_dashboard_partials(service_id):
all_statistics = template_statistics_client.get_template_statistics_for_service(service_id, limit_days=7)
template_statistics = aggregate_template_usage(all_statistics)
stats = aggregate_notifications_stats(all_statistics)
column_width, max_notifiction_count = get_column_properties(3)
dashboard_totals = get_dashboard_totals(stats),
highest_notification_count = max(
sum(
value[key] for key in {'requested', 'failed', 'delivered'}
)
for key, value in dashboard_totals[0].items()
)
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(
current_service.id,
get_current_financial_year(),
@@ -312,10 +305,6 @@ def get_dashboard_partials(service_id):
'views/dashboard/_totals.html',
service_id=service_id,
statistics=dashboard_totals[0],
column_width=column_width,
smaller_font_size=(
highest_notification_count > max_notifiction_count
),
),
'template-statistics': render_template(
'views/dashboard/template-statistics.html',
@@ -330,7 +319,6 @@ def get_dashboard_partials(service_id):
),
'usage': render_template(
'views/dashboard/_usage.html',
column_width=column_width,
**calculate_usage(yearly_usage, free_sms_allowance),
),
}
@@ -505,10 +493,3 @@ def get_tuples_of_financial_years(
)
for year in range(start, end + 1)
)
def get_column_properties(number_of_columns):
return {
2: ('column-half', 999999999),
3: ('column-third', 99999),
}.get(number_of_columns)

View File

@@ -3,7 +3,7 @@
<div class="ajax-block-container">
<div class="grid-row">
<div id="total-email" class="{{column_width}}">
<div id="total-email" class="column-third">
{{ big_number_with_status(
statistics['email']['requested'],
message_count_label(statistics['email']['requested'], 'email', suffix='sent'),
@@ -12,10 +12,10 @@
statistics['email']['show_warning'],
failure_link=url_for(".view_notifications", service_id=service_id, message_type='email', status='failed'),
link=url_for(".view_notifications", service_id=service_id, message_type='email', status='sending,delivered,failed'),
smaller=smaller_font_size
smaller=True,
) }}
</div>
<div id="total-sms" class="{{column_width}}">
<div id="total-sms" class="column-third">
{{ big_number_with_status(
statistics['sms']['requested'],
message_count_label(statistics['sms']['requested'], 'sms', suffix='sent'),
@@ -24,10 +24,10 @@
statistics['sms']['show_warning'],
failure_link=url_for(".view_notifications", service_id=service_id, message_type='sms', status='failed'),
link=url_for(".view_notifications", service_id=service_id, message_type='sms', status='sending,delivered,failed'),
smaller=smaller_font_size
smaller=True,
) }}
</div>
<div id="total-letters" class="{{column_width}}">
<div id="total-letters" class="column-third">
{{ big_number_with_status(
statistics['letter']['requested'],
message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'),
@@ -36,7 +36,7 @@
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
smaller=True,
) }}
</div>
</div>

View File

@@ -1,12 +1,12 @@
{% from "components/big-number.html" import big_number %}
<div class='grid-row ajax-block-container'>
<div class='{{ column_width }}'>
<div class='column-third'>
<div class="keyline-block">
{{ big_number("Unlimited", 'free email allowance', smaller=True) }}
</div>
</div>
<div class='{{ column_width }}'>
<div class='column-third'>
<div class="keyline-block">
{% if sms_chargeable %}
{{ big_number(
@@ -20,7 +20,7 @@
{% endif %}
</div>
</div>
<div class='{{ column_width }}'>
<div class='column-third'>
<div class="keyline-block">
{{ big_number(
letter_cost,

View File

@@ -553,7 +553,7 @@ def test_should_not_show_recent_templates_on_dashboard_if_only_one_template_used
expected_count = stats[0]['count']
assert expected_count == 50
assert normalize_spaces(
page.select_one('#total-sms .big-number').text
page.select_one('#total-sms .big-number-smaller').text
) == (
'{} text messages sent'.format(expected_count)
)
@@ -713,14 +713,13 @@ def test_should_show_upcoming_jobs_on_dashboard(
['email', 'sms'],
['email', 'sms', 'letter'],
))
@pytest.mark.parametrize('totals, big_number_class', [
@pytest.mark.parametrize('totals', [
(
{
'email': {'requested': 0, 'delivered': 0, 'failed': 0},
'sms': {'requested': 99999, 'delivered': 0, 'failed': 0},
'letter': {'requested': 99999, 'delivered': 0, 'failed': 0}
},
'.big-number',
),
(
{
@@ -728,7 +727,6 @@ def test_should_show_upcoming_jobs_on_dashboard(
'sms': {'requested': 0, 'delivered': 0, 'failed': 0},
'letter': {'requested': 100000, 'delivered': 0, 'failed': 0},
},
'.big-number-smaller',
),
])
def test_correct_font_size_for_big_numbers(
@@ -743,7 +741,6 @@ def test_correct_font_size_for_big_numbers(
service_one,
permissions,
totals,
big_number_class,
):
service_one['permissions'] = permissions
@@ -758,11 +755,12 @@ def test_correct_font_size_for_big_numbers(
service_id=service_one['id'],
)
assert len(page.select_one('[data-key=totals]').select('.column-third')) == 3
assert len(page.select_one('[data-key=usage]').select('.column-third')) == 3
assert len(
page.select('.big-number-with-status {}'.format(big_number_class))
assert (
len(page.select_one('[data-key=totals]').select('.column-third'))
) == (
len(page.select_one('[data-key=usage]').select('.column-third'))
) == (
len(page.select('.big-number-with-status .big-number-smaller'))
) == 3