From 4ac1a03a8931e50c015eee6d4e77bda9b2fe3037 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Jun 2016 14:48:21 +0100 Subject: [PATCH] Use message_count_label component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the button on the check page, we need to be able to say ‘1 text message’ or ‘55 emails’. We already have the logic to do this on the dashboard (101 text messages sent), and it’s already in a component. So this commit makes the check page use the same component. --- app/main/views/send.py | 14 -------------- app/templates/components/message-count-label.html | 8 ++++---- app/templates/views/check.html | 3 ++- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index e7a8a9447..b4379973e 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -31,19 +31,6 @@ from app import job_api_client, service_api_client, current_service, user_api_cl from app.utils import user_has_permissions, get_errors_for_csv, Spreadsheet -def get_send_button_text(template_type, number_of_messages): - if 1 == number_of_messages: - return { - 'email': 'Send 1 email', - 'sms': 'Send 1 text message' - }[template_type] - else: - return { - 'email': 'Send {} emails', - 'sms': 'Send {} text messages' - }[template_type].format(number_of_messages) - - def get_page_headings(template_type): return { 'email': 'Email templates', @@ -279,7 +266,6 @@ def check_messages(service_id, template_type, upload_id): len(list(recipients.initial_annotated_rows)) ), original_file_name=session['upload_data'].get('original_file_name'), - send_button_text=get_send_button_text(template.template_type, session['upload_data']['notification_count']), upload_id=upload_id, form=CsvUploadForm(), statistics=statistics, diff --git a/app/templates/components/message-count-label.html b/app/templates/components/message-count-label.html index 532a711d5..a4d59afed 100644 --- a/app/templates/components/message-count-label.html +++ b/app/templates/components/message-count-label.html @@ -1,4 +1,4 @@ -{% macro message_count_label(count, template_type) -%} +{% macro message_count_label(count, template_type, suffix='sent') -%} {%- if template_type == 'sms' -%} {%- if count == 1 -%} text message @@ -10,6 +10,6 @@ email {%- else -%} emails - {%- endif -%} - {%- endif %} sent -{%- endmacro %} \ No newline at end of file + {%- endif -%} + {%- endif %} {{ suffix }} +{%- endmacro %} diff --git a/app/templates/views/check.html b/app/templates/views/check.html index e36d913fb..1f95a4d9e 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -7,6 +7,7 @@ {% from "components/file-upload.html" import file_upload %} {% from "components/page-footer.html" import page_footer %} {% from "components/list.html" import formatted_list %} +{% from "components/message-count-label.html" import message_count_label %} {% block page_title %} {{ page_heading if errors else "Check and confirm" }} – GOV.UK Notify @@ -175,7 +176,7 @@ {% endif %}