From 3ace856d74058d6f0a488929f196ebb3ea349c44 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 3 Jun 2016 14:38:10 +0100 Subject: [PATCH] Only show row-level errors if all columns are OK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Row-level errors are: - bad phone number/email address - missing data I think it’s distracting to show these on the page if there’s something more fundamentally wrong with the file, eg placeholders don’t match. So this commit makes sure that these error messages are only displayed when the top-level error says ‘There is a problem with your data’ --- app/main/views/send.py | 2 +- app/templates/views/check.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 237e73337..e7a8a9447 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -275,7 +275,7 @@ def check_messages(service_id, template_type, upload_id): count_of_recipients=session['upload_data']['notification_count'], count_of_displayed_recipients=( len(list(recipients.initial_annotated_rows_with_errors)) - if any(recipients.rows_with_errors) else + if any(recipients.rows_with_errors) and not recipients.missing_column_headers else len(list(recipients.initial_annotated_rows)) ), original_file_name=session['upload_data'].get('original_file_name'), diff --git a/app/templates/views/check.html b/app/templates/views/check.html index 1b55742e5..1eec4a52c 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -191,13 +191,13 @@ {% endif %} {% call(item, row_number) list_table( - recipients.initial_annotated_rows_with_errors if row_errors else recipients.initial_annotated_rows, + recipients.initial_annotated_rows_with_errors if row_errors and not recipients.missing_column_headers else recipients.initial_annotated_rows, caption=original_file_name, field_headings=['1'] + recipients.column_headers ) %} {{ index_field(item.index + 2) }} {% for column in recipients.column_headers %} - {% if item['columns'][column].error %} + {% if item['columns'][column].error and not recipients.missing_column_headers %} {% call field() %} {{ item['columns'][column].error }} @@ -223,13 +223,13 @@ {% if count_of_displayed_recipients < count_of_recipients %} - {% elif row_errors %} + {% elif row_errors and not recipients.missing_column_headers %}