Use message_count_label component

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.
This commit is contained in:
Chris Hill-Scott
2016-06-03 14:48:21 +01:00
parent 9332f57f55
commit 4ac1a03a89
3 changed files with 6 additions and 19 deletions

View File

@@ -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,

View File

@@ -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 %}
{%- endif -%}
{%- endif %} {{ suffix }}
{%- endmacro %}

View File

@@ -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 @@
<form method="post" enctype="multipart/form-data" action="{{url_for('main.start_job', service_id=current_service.id, upload_id=upload_id)}}" class='page-footer'>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="help" value="{{ '3' if request.args['help'] == '2' else 0 }}" />
<input type="submit" class="button" value="{{ send_button_text }}" />
<input type="submit" class="button" value="Send {{ count_of_recipients }} {{ message_count_label(count_of_recipients, template.template_type, suffix='') }}" />
<a href="{{ back_link }}" class="page-footer-back-link">Back</a>
</form>
{% endif %}