From 7e699c93ca9163b66318a51d1ceb5ce3b635a3f3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 25 Oct 2019 15:01:27 +0100 Subject: [PATCH] Always show letters on the usage page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if your service doesn’t send letters now, it might have done previously. The original reason for hiding letters was because it wasn’t a mature feature. But now that it is, we should make it discoverable even for existing teams. So that means not conditionally hiding it. This is the same thing we do for emails/texts, where even if you switch them off they still show up on the dashboard and usage page. --- app/main/views/dashboard.py | 5 +- app/templates/views/usage.html | 117 ------------------------- tests/app/main/views/test_dashboard.py | 4 +- 3 files changed, 3 insertions(+), 123 deletions(-) delete mode 100644 app/templates/views/usage.html diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index b7e64997c..60f7a8e8b 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -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-with-letters.html', months=list(get_free_paid_breakdown_for_billable_units( year, free_sms_allowance, diff --git a/app/templates/views/usage.html b/app/templates/views/usage.html deleted file mode 100644 index fb10e8581..000000000 --- a/app/templates/views/usage.html +++ /dev/null @@ -1,117 +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 %} - -

Usage

- -
- {{ pill(years, selected_year, big_number_args={'smallest': True}) }} -
-
-
-
-

Emails

-
- {{ big_number(emails_sent, 'sent', smaller=True) }} - {{ big_number("Unlimited", 'free allowance', smaller=True) }} -
-
-
-

Text messages

-
- {{ 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 %} -
-
-
- -
-
-
-   -
-
-
-
- {{ big_number( - (sms_chargeable * sms_rate), - 'spent', - currency="£", - smaller=True - ) }} -
-
-
- - {% if months %} -
- {% 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, - currency="£", - smallest=True - ) }} -
    - {% if month.free %} -
  • {{ "{:,}".format(month.free) }} free {{ message_count_label(month.free, 'sms', '') }}
  • - {% endif %} - {% if month.paid %} -
  • {{ "{:,}".format(month.paid) }} {{ message_count_label(month.free, 'sms', '') }}at - {{- ' {:.2f}p'.format(sms_rate * 100) }}
  • - {% endif %} - {% if not (month.free or month.paid) %} - - {% endif %} -
- {% endcall %} - {% endcall %} -
- {% endif %} -
- -
-
-

- Financial year ends 31 March. -

-
-
-

- What counts as 1 text message?
- See pricing. -

-
-
- -{% endblock %} diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index c06057af1..932b9065e 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -795,7 +795,7 @@ def test_usage_page( mock_get_usage.assert_called_once_with(SERVICE_ONE_ID, 2011) mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011) - cols = page.find_all('div', {'class': 'column-half'}) + cols = page.find_all('div', {'class': 'column-one-third'}) nav = page.find('ul', {'class': 'pill', 'role': 'tablist'}) nav_links = nav.find_all('a') @@ -813,7 +813,7 @@ def test_usage_page( assert 'April' in table assert 'February' in table assert 'March' in table - assert '£15.84' in table + assert '£20.59' in table assert '140 free text messages' in table assert '£20.30' in table assert '1,230 text messages at 1.65p' in table