Catch duplicate recipient columns in spreadsheets

If someone has duplicate recipient columns in their file we don’t know
which one to use. This commit adds an error message which should help
them fix the duplication.

This commit doesn’t go to the extra effort to actually show the
correct values for duplication in the preview. Don’t think it’s worth
the effort/complexity for how infrequently we’ve seen this error.

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/376
This commit is contained in:
Chris Hill-Scott
2018-03-02 10:45:29 +00:00
parent ea94d466b6
commit a4424e999f
4 changed files with 66 additions and 3 deletions

View File

@@ -69,6 +69,21 @@
) }}.
</p>
{% elif recipients.duplicate_recipient_column_headers %}
<h1 class='banner-title' data-module="track-error" data-error-type="Duplicate recipient columns" data-error-label="{{ upload_id }}">
Your file has more than one column called {{ (
recipients.duplicate_recipient_column_headers
) | formatted_list(
conjunction='or',
prefix='',
prefix_plural=''
) }}
</h1>
<p>
Delete or rename one of these columns and try again.
</p>
{% elif recipients.missing_column_headers %}
<h1 class='banner-title' data-module="track-error" data-error-type="Missing placeholder columns" data-error-label="{{ upload_id }}">
@@ -128,6 +143,8 @@
{% if not request.args.from_test %}
{% set column_headers = recipients._raw_column_headers if recipients.duplicate_recipient_column_headers else recipients.column_headers %}
<h2 class="heading-medium" id="{{ file_contents_header_id }}">{{ original_file_name }}</h2>
<div class="fullscreen-content" data-module="fullscreen-table">
@@ -137,14 +154,14 @@
caption_visible=False,
field_headings=[
'<span class="visually-hidden">Row in file</span><span aria-hidden="true">1</span>'|safe
] + recipients.column_headers
] + column_headers
) %}
{% call index_field() %}
<span>
{{ item.index + 2 }}
</span>
{% endcall %}
{% for column in recipients.column_headers %}
{% for column in column_headers %}
{% if item['columns'][column].error and not recipients.missing_column_headers %}
{% call field() %}
<span>