Accept CSVs with 'email address' or 'phone number'

CSV files currently have ‘to’ as the recipient column. This is changing in
https://github.com/alphagov/notifications-api/pull/109

The admin app also has to validate that the CSV files have the right columns,
because the API expects any CSV that it’s given to have been checked (also we
want things to actually work).

This commit is the minimum code change needed. In the future it should reuse
the same code as the API for processing CSV files. This will need more thinking.
This commit is contained in:
Chris Hill-Scott
2016-03-01 09:41:08 +00:00
parent 900f4cd7ff
commit b57ac2f7e5
6 changed files with 48 additions and 30 deletions

View File

@@ -61,13 +61,17 @@
caption=original_file_name,
field_headings=column_headers
) %}
{% if item.to or ''|valid_phone_number %}
{% if item.get('phone number', '')|valid_phone_number %}
{% call field() %}
{{ item.to }}
{{ item['phone number'] }}
{% endcall %}
{% elif item.get('email address') %}
{% call field() %}
{{ item['email address'] }}
{% endcall %}
{% else %}
{% call field(status='missing') %}
{{ item.to }}
{{ item['phone number'] }}
{% endcall %}
{% endif %}
{% for column in template.placeholders %}