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:
Chris Hill-Scott
2016-02-12 10:55:21 +00:00
parent 2a9f9dcc57
commit eec56c2778
6 changed files with 43 additions and 10 deletions

View File

@@ -1,8 +1,7 @@
import csv
import io
import uuid
import botocore
import re
import io
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'})
@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>",
methods=['GET', 'POST'])
@login_required

View File

@@ -48,7 +48,7 @@ def add_service_template(service_id):
if form.validate_on_submit():
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(
'.manage_service_templates', service_id=service_id))
return render_template(