mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 06:18:25 -04:00
First slice of csv upload of phone numbers for sending messages.
At the moment the file contents are not persisted by checked in memory. The first and last three records are show if all are valid. If there are invalid rows, they are reported and the user is prompted to go back and sort out upload file. The storing of upload result (i.e. validation of file) in session will be removed in next story which is about persisting of file for later processing.
This commit is contained in:
@@ -10,57 +10,55 @@
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<h1 class="heading-xlarge">Send text messages</h1>
|
||||
|
||||
<h1 class="heading-xlarge">Send text messages</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('.sendsms')}}" class="button">Go back and resolve errors</a></p>
|
||||
|
||||
<h2 class="heading-medium">Check and confirm</h2>
|
||||
{% else %}
|
||||
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<h2 class="heading-medium">Check and confirm</h2>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
|
||||
{{ page_footer(
|
||||
"Send {} text messages".format(number_of_recipients)
|
||||
) }}
|
||||
|
||||
<h3 class="heading-small">First 3 messages</h2>
|
||||
|
||||
{% if recipients.first_three and recipients.last_three %}
|
||||
|
||||
{% for recipient in recipients.first_three %}
|
||||
{{ sms_message(
|
||||
message_template|replace_placeholders(recipient),
|
||||
"{}".format(recipient['phone'])
|
||||
) }}
|
||||
{% endfor %}
|
||||
|
||||
<h3 class="heading-small">Last 3 messages</h2>
|
||||
|
||||
{% for recipient in recipients.last_three %}
|
||||
{{ sms_message(
|
||||
message_template|replace_placeholders(recipient),
|
||||
"{}".format(recipient['phone'])
|
||||
) }}
|
||||
{% endfor %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% for recipient in recipients.all %}
|
||||
{{ sms_message(
|
||||
message_template|replace_placeholders(recipient),
|
||||
"{}".format(recipient['phone'])
|
||||
) }}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<a href="#">See all</a>
|
||||
</p>
|
||||
|
||||
{{ page_footer(
|
||||
button_text = "Send {} text messages".format(number_of_recipients),
|
||||
{{ page_footer(
|
||||
button_text = "Send {} text messages".format(upload_result.valid|count),
|
||||
back_link = url_for(".sendsms")
|
||||
) }}
|
||||
)}}
|
||||
|
||||
</form>
|
||||
{% if upload_result.valid | count > 6 %}
|
||||
<h3 class="heading-small">First three message in file</h3>
|
||||
{% for recipient in upload_result.valid[:3] %}
|
||||
{{ sms_message(message_template|replace_placeholders(
|
||||
recipient),
|
||||
'{}'.format(recipient['phone'])
|
||||
)}}
|
||||
{% endfor %}
|
||||
<h3 class="heading-small">Last three messages in file</h3>
|
||||
{% for recipient in upload_result.valid[-3:] %}
|
||||
{{ sms_message(message_template|replace_placeholders(
|
||||
recipient),
|
||||
'{}'.format(recipient['phone'])
|
||||
)}}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<h3 class="heading-small">All messages in file</h3>
|
||||
{% for recipient in upload_result.valid %}
|
||||
{{ sms_message(message_template|replace_placeholders(
|
||||
recipient),
|
||||
'{}'.format(recipient['phone'])
|
||||
)}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{{ page_footer(
|
||||
button_text = "Send {} text messages".format(upload_result.valid|count),
|
||||
back_link = url_for(".sendsms")
|
||||
)}}
|
||||
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/sms-message.html" import sms_message %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/form-field.html" import render_field %}
|
||||
|
||||
{% block page_title %}
|
||||
GOV.UK Notify | Send text messages
|
||||
@@ -37,7 +38,7 @@
|
||||
You can also <a href="#">download an example CSV</a>.
|
||||
</p>
|
||||
<p>
|
||||
<input type="file" />
|
||||
{{render_field(form.file)}}
|
||||
</p>
|
||||
|
||||
{{ page_footer("Continue") }}
|
||||
|
||||
Reference in New Issue
Block a user