From 42e33ce9e6f5207d60abde0aef5273f14142316f Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 29 Jun 2017 15:33:31 +0100 Subject: [PATCH] make partials source-agnostic they're currently expecting a RecipientsCSV object - but we won't always have that available if we're handling a single notification. So make the partials take generic variables, and then use a jinja with block to pass in the correct values from either the check csv page or the check notification page. Additionally set the notification check page to show errors nicely - hide the send button if there were problems, and replace the header --- .../partials/check/message-too-long.html | 3 +- .../check/not-allowed-to-send-to.html | 12 +++++- app/templates/views/check.html | 7 +++- app/templates/views/notifications/check.html | 37 ++++++++++++------- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/app/templates/partials/check/message-too-long.html b/app/templates/partials/check/message-too-long.html index 5dde66856..9b3e2b8f4 100644 --- a/app/templates/partials/check/message-too-long.html +++ b/app/templates/partials/check/message-too-long.html @@ -4,7 +4,8 @@ Message too long

- Text messages can’t be longer than {{ template|string|length }} characters. Your message is {{message_length}} characters. + Text messages can’t be longer than {{ SMS_CHAR_COUNT_LIMIT }} characters. + Your message is {{ template.content_count }} characters.

{% endcall %} diff --git a/app/templates/partials/check/not-allowed-to-send-to.html b/app/templates/partials/check/not-allowed-to-send-to.html index 932bbbb4c..5d2f001fb 100644 --- a/app/templates/partials/check/not-allowed-to-send-to.html +++ b/app/templates/partials/check/not-allowed-to-send-to.html @@ -1,11 +1,19 @@ +{% from "components/banner.html" import banner_wrapper %} + +{% macro skip_to_file_contents() %} +

+ Skip to file contents +

+{% endmacro %} +
{% call banner_wrapper(type='dangerous') %}

You can’t send to {{ 'this' if count_of_recipients == 1 else 'these' }} - {{ recipients.recipient_column_headers[0] }} + {{ template_type_label }} {%- if count_of_recipients != 1 -%} - {{ 'es' if 'email address' == recipients.recipient_column_headers[0] else 's' }} + {{ 'es' if 'email address' == template_type_label else 's' }} {%- endif %}

diff --git a/app/templates/views/check.html b/app/templates/views/check.html index 67048a016..e09bbd556 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -120,7 +120,12 @@

{% elif not recipients.allowed_to_send_to %} - {% include "partials/check/not-allowed-to-send-to.html" %} + {% with + count_of_recipients=count_of_recipients, + template_type_label=recipients.recipient_column_headers[0] + %} + {% include "partials/check/not-allowed-to-send-to.html" %} + {% endwith %} {% elif recipients.more_rows_than_can_send %} {% include "partials/check/too-many-messages.html" %} {% else %} diff --git a/app/templates/views/notifications/check.html b/app/templates/views/notifications/check.html index ae6a29bb3..727b07e21 100644 --- a/app/templates/views/notifications/check.html +++ b/app/templates/views/notifications/check.html @@ -1,20 +1,29 @@ {% extends "withnav_template.html" %} - - - - {% from "components/radios.html" import radio_select %} {% from "components/message-count-label.html" import message_count_label %} {% block service_page_title %} - {{ "Error" if errors else "Preview" }} + {{ "Error" if error else "Preview" }} {% endblock %} {% block maincolumn_content %} - -

- Preview of {{ template.name }} -

+ {% if error == 'not-allowed-to-send-to' %} + {% with + count_of_recipients=1, + template_type_label='phone number' + %} + {% include "partials/check/not-allowed-to-send-to.html" %} + {% endwith %} + {% elif error == 'more_rows_than_can_send' %} + {% include "partials/check/too-many-messages.html" %} + {% elif error == 'row_errors' %} + {# the only row_errors we can get when sending one off messages is that the message is too long #} + {% include "partials/check/message-too-long.html" %} + {% else %} +

+ Preview of {{ template.name }} +

+ {% endif %} {{ template|string }} @@ -22,10 +31,12 @@