Merge pull request #1634 from alphagov/smaller-font-for-bigger-numbers

Make dashboard totals smaller if numbers are big
This commit is contained in:
Chris Hill-Scott
2017-11-17 13:29:39 +00:00
committed by GitHub
4 changed files with 103 additions and 8 deletions

View File

@@ -10,7 +10,6 @@ from flask import (
Response,
)
from flask_login import login_required
from notifications_utils.recipients import format_phone_number_human_readable
from app.main import main
@@ -303,7 +302,18 @@ def get_dashboard_partials(service_id):
for job in job_api_client.get_jobs(service_id, limit_days=7, statuses=statuses_to_display)['data']
]
service = service_api_client.get_detailed_service(service_id)
column_width = 'column-third' if 'letter' in current_service['permissions'] else 'column-half'
column_width, max_notifiction_count = get_column_properties(
number_of_columns=(
3 if 'letter' in current_service['permissions'] else 2
)
)
dashboard_totals = get_dashboard_totals(service['data']['statistics']),
highest_notification_count = max(
sum(
value[key] for key in {'requested', 'failed', 'delivered'}
)
for key, value in dashboard_totals[0].items()
)
return {
'upcoming': render_template(
@@ -320,8 +330,11 @@ def get_dashboard_partials(service_id):
'totals': render_template(
'views/dashboard/_totals.html',
service_id=service_id,
statistics=get_dashboard_totals(service['data']['statistics']),
column_width=column_width
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',
@@ -496,3 +509,10 @@ 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)