Files
notifications-admin/app/templates/views/check-sms.html
Chris Hill-Scott efb2140bbb Check CSV files match the template
This commit adds a first stab at checking whether a CSV file has the right
data to fill the placeholders.

The UI is very much first bash, but I’d like to get this merged and see how it
feels. The main thing is that we’ve got all the bit in place now to do this
logic.
2016-02-18 15:07:14 +00:00

85 lines
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "withnav_template.html" %}
{% from "components/sms-message.html" import sms_message %}
{% from "components/table.html" import list_table, field %}
{% from "components/placeholder.html" import placeholder %}
{% from "components/file-upload.html" import file_upload %}
{% from "components/page-footer.html" import page_footer %}
{% block page_title %}
Check and confirm GOV.UK Notify
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Check and confirm</h1>
{% if upload_result.rejects %}
<h3 class="heading-small">The following numbers are invalid</h3>
{% for rejected in upload_result.rejects %}
<p>Line {{rejected.line_number}}: {{rejected.phone }}</a>
{% endfor %}
<p><a href="{{url_for('.send_sms', service_id=service_id, template_id=template.id)}}" class="button">Go back and resolve errors</a></p>
{% else %}
<div class="grid-row">
<div class="column-two-thirds">
{% if template.missing_data or template.additional_data %}
{{ sms_message(template.formatted_as_markup)}}
{% else %}
{{ sms_message(template.replaced)}}
{% endif %}
</div>
</div>
{% if template.missing_data %}
{{ banner(
"Add these columns to your CSV file: " + ", ".join(template.missing_data),
type="dangerous"
) }}
{% elif template.additional_data %}
{{ banner(
"Remove these columns from your CSV file:" + ", ".join(template.missing_data),
type="dangerous"
) }}
{% else %}
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="button" value="{{ "Send {} text message{}".format(upload_result.valid|count, '' if upload_result.valid|count == 1 else 's') }}" />
<a href="{{url_for('.send_sms', service_id=service_id, template_id=template.id)}}" class="page-footer-back-link">Back</a>
</form>
{% endif %}
{% if template.missing_data or template.additional_data %}
<form method="post" action="{{ url_for('.send_sms', service_id=service_id, template_id=template.id) }}" enctype="multipart/form-data">
{{file_upload(form.file, button_text='Choose a CSV file')}}
{{ page_footer(
"Upload"
) }}
</form>
{% endif %}
{% call(item) list_table(
upload_result.valid,
caption=original_file_name,
field_headings=column_headers
) %}
{% call field() %}
{{ item.phone }}
{% endcall %}
{% for column in template.placeholders %}
{% if item.get(column) %}
{% call field() %}
{{ item.get(column) }}
{% endcall %}
{% else %}
{% call field(status='missing') %}
missing
{% endcall %}
{% endif %}
{% endfor %}
{% endcall %}
{% endif %}
{% endblock %}