mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 00:28:26 -04:00
Add flow for sending yourself a text message
This commit adds a shortcut, which (in the background) does the creation and uploading of a CSV file for you. This enables users to send themselves a test message without having to fiddle about with CSV files.
This commit is contained in:
@@ -36,7 +36,20 @@
|
|||||||
z-index: 50;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sms-message-use-link {
|
.sms-message-use-links {
|
||||||
@include bold-19;
|
|
||||||
margin-top: 70px;
|
@include copy-19;
|
||||||
|
margin-top: 55px;
|
||||||
|
|
||||||
|
a {
|
||||||
|
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
@include bold-19;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import csv
|
import csv
|
||||||
|
import io
|
||||||
import uuid
|
import uuid
|
||||||
import botocore
|
import botocore
|
||||||
import re
|
|
||||||
import io
|
|
||||||
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
@@ -102,6 +101,26 @@ def get_example_csv(service_id, template_id):
|
|||||||
return(output.getvalue(), 200, {'Content-Type': 'text/csv; charset=utf-8'})
|
return(output.getvalue(), 200, {'Content-Type': 'text/csv; charset=utf-8'})
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/services/<service_id>/sms/send/<template_id>/to-self", methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
def send_sms_to_self(service_id, template_id):
|
||||||
|
output = io.StringIO()
|
||||||
|
writer = csv.writer(output)
|
||||||
|
writer.writerow(['phone'])
|
||||||
|
writer.writerow([current_user.mobile_number])
|
||||||
|
filedata = {
|
||||||
|
'file_name': 'Test run',
|
||||||
|
'data': output.getvalue().splitlines()
|
||||||
|
}
|
||||||
|
upload_id = str(uuid.uuid4())
|
||||||
|
s3upload(upload_id, service_id, filedata, current_app.config['AWS_REGION'])
|
||||||
|
session['upload_data'] = {"template_id": template_id, "original_file_name": filedata['file_name']}
|
||||||
|
|
||||||
|
return redirect(url_for('.check_sms',
|
||||||
|
service_id=service_id,
|
||||||
|
upload_id=upload_id))
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<service_id>/sms/check/<upload_id>",
|
@main.route("/services/<service_id>/sms/check/<upload_id>",
|
||||||
methods=['GET', 'POST'])
|
methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def add_service_template(service_id):
|
|||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
tdao.insert_service_template(
|
tdao.insert_service_template(
|
||||||
form.name.data, 'sms', form.template_content.data, service_id)
|
form.name.data, form.template_content.data, service_id)
|
||||||
return redirect(url_for(
|
return redirect(url_for(
|
||||||
'.manage_service_templates', service_id=service_id))
|
'.manage_service_templates', service_id=service_id))
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
{{ sms_message(template.formatted_as_markup, name=template.name) }}
|
{{ sms_message(template.formatted_as_markup, name=template.name) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="column-one-third">
|
<div class="column-one-third">
|
||||||
<div class="sms-message-use-link">
|
<div class="sms-message-use-links">
|
||||||
<a href="{{ url_for(".send_sms", service_id=service_id, template_id=template.id) }}">Use this template</a>
|
<a href="{{ url_for(".send_sms", service_id=service_id, template_id=template.id) }}">Add recipients</a>
|
||||||
|
<a href="{{ url_for(".send_sms_to_self", service_id=service_id, template_id=template.id) }}">Send yourself a test</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
{% call(item) list_table(
|
{% call(item) list_table(
|
||||||
[
|
[
|
||||||
{'row': 1, 'phone': '+447700 900995', 'template': template['name'], 'status': 'queued'}
|
{'row': 1, 'phone': '+447700 900995', 'template': template['name'], 'status': 'sent'}
|
||||||
],
|
],
|
||||||
caption=uploaded_file_name,
|
caption=uploaded_file_name,
|
||||||
caption_visible=False,
|
caption_visible=False,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
<h1 class="heading-large">Send text messages</h1>
|
<h1 class="heading-large">Add recipients</h1>
|
||||||
|
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user