diff --git a/app/main/views/send.py b/app/main/views/send.py
index 9cdd56419..ba92533d4 100644
--- a/app/main/views/send.py
+++ b/app/main/views/send.py
@@ -450,6 +450,14 @@ def check_messages(service_id, template_type, upload_id):
data = _check_messages(service_id, template_type, upload_id)
+ if (
+ data['recipients'].too_many_rows or
+ not data['count_of_recipients'] or
+ not data['recipients'].has_recipient_columns or
+ data['recipients'].missing_column_headers
+ ):
+ return render_template('views/check/column-errors.html', **data)
+
if data['row_errors']:
return render_template('views/check/row-errors.html', **data)
diff --git a/app/templates/views/check/column-errors.html b/app/templates/views/check/column-errors.html
index ebb207edd..d331eb1a2 100644
--- a/app/templates/views/check/column-errors.html
+++ b/app/templates/views/check/column-errors.html
@@ -14,7 +14,7 @@
{% endmacro %}
{% block service_page_title %}
- {{ "Error" if errors else "Preview of {}".format(template.name) }}
+ Error
{% endblock %}
{% block maincolumn_content %}
@@ -91,34 +91,6 @@
{% endcall %}
- {% elif row_errors %}
-
-
- {% call banner_wrapper(type='dangerous') %}
- {% if row_errors|length == 1 %}
-
- There is a problem with your data
-
-
- You need to {{ row_errors[0] }}
-
- {% else %}
-
- There are some problems with your data
-
-
- You need to:
-
-
- {% for error in row_errors %}
- - {{ error }}
- {% endfor %}
-
- {% endif %}
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
{% elif not recipients.allowed_to_send_to %}
{% with
count_of_recipients=count_of_recipients,
@@ -128,44 +100,14 @@
{% endwith %}
{% elif recipients.more_rows_than_can_send %}
{% include "partials/check/too-many-messages.html" %}
- {% else %}
-
-
- Preview of {{ template.name }}
-
- {{ skip_to_file_contents() }}
-
- {% endif %}
-
- {% if not errors %}
- {{ template|string }}
{% endif %}
- {% if errors %}
{% if request.args.from_test %}
{% else %}
{{file_upload(form.file, button_text='Re-upload your file')}}
{% endif %}
- {% else %}
-
- {% endif %}
{% if not request.args.from_test %}
@@ -227,9 +169,7 @@
{% endif %}
- {% if errors %}
- Preview of {{ template.name }}
- {{ template|string }}
- {% endif %}
+ Preview of {{ template.name }}
+ {{ template|string }}
{% endblock %}
diff --git a/app/templates/views/check/row-errors.html b/app/templates/views/check/row-errors.html
index ebb207edd..8071e7804 100644
--- a/app/templates/views/check/row-errors.html
+++ b/app/templates/views/check/row-errors.html
@@ -14,158 +14,43 @@
{% endmacro %}
{% block service_page_title %}
- {{ "Error" if errors else "Preview of {}".format(template.name) }}
+ Error
{% endblock %}
{% block maincolumn_content %}
- {% if recipients.too_many_rows %}
-
-
- {% call banner_wrapper(type='dangerous') %}
+
+ {% call banner_wrapper(type='dangerous') %}
+ {% if row_errors|length == 1 %}
- Your file has too many rows
+ There is a problem with your data
- Notify can process up to
- {{ "{:,}".format(recipients.max_rows) }} rows at once. Your
- file has {{ "{:,}".format(recipients|length) }} rows.
+ You need to {{ row_errors[0] }}
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
- {% elif not count_of_recipients %}
-
-
- {% call banner_wrapper(type='dangerous') %}
+ {% else %}
- Your file is missing some rows
+ There are some problems with your data
- It needs at least one row of data, and {{ recipients.missing_column_headers | sort() | formatted_list(
- prefix='a column called',
- prefix_plural='columns called'
- ) }}.
+ You need to:
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
- {% elif not recipients.has_recipient_columns %}
-
-
- {% call banner_wrapper(type='dangerous') %}
-
- Your file needs {{ recipients.recipient_column_headers | formatted_list(
- prefix='a column called',
- prefix_plural='columns called'
- ) }}
-
-
- Right now it has {{ recipients.column_headers | formatted_list(
- prefix='one column, called ',
- prefix_plural='columns called '
- ) }}.
-
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
- {% elif recipients.missing_column_headers %}
-
-
- {% call banner_wrapper(type='dangerous') %}
-
- The columns in your file need to match the double brackets in
- your template
-
-
- Your file is missing {{ recipients.missing_column_headers | formatted_list(
- conjunction='and',
- prefix='a column called ',
- prefix_plural='columns called '
- ) }}.
-
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
- {% elif row_errors %}
-
-
- {% call banner_wrapper(type='dangerous') %}
- {% if row_errors|length == 1 %}
-
- There is a problem with your data
-
-
- You need to {{ row_errors[0] }}
-
- {% else %}
-
- There are some problems with your data
-
-
- You need to:
-
-
- {% for error in row_errors %}
- - {{ error }}
- {% endfor %}
-
- {% endif %}
- {{ skip_to_file_contents() }}
- {% endcall %}
-
-
- {% elif not recipients.allowed_to_send_to %}
- {% 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 %}
-
-
- Preview of {{ template.name }}
-
- {{ skip_to_file_contents() }}
-
- {% endif %}
-
- {% if not errors %}
- {{ template|string }}
- {% endif %}
+
+ {% for error in row_errors %}
+ - {{ error }}
+ {% endfor %}
+
+ {% endif %}
+ {{ skip_to_file_contents() }}
+ {% endcall %}
+
- {% if errors %}
{% if request.args.from_test %}
{% else %}
{{file_upload(form.file, button_text='Re-upload your file')}}
{% endif %}
- {% else %}
-
- {% endif %}
{% if not request.args.from_test %}
@@ -208,12 +93,7 @@
{% endif %}
-
- {% if recipients.too_many_rows %}
-
- Can’t show the contents of this file
-
- {% elif count_of_displayed_recipients < count_of_recipients %}
+ {% if count_of_displayed_recipients < count_of_recipients %}
{% if row_errors and not recipients.missing_column_headers %}
Only showing the first {{ count_of_displayed_recipients }} rows with errors
@@ -227,9 +107,7 @@
{% endif %}
- {% if errors %}
- Preview of {{ template.name }}
- {{ template|string }}
- {% endif %}
+ Preview of {{ template.name }}
+ {{ template|string }}
{% endblock %}