From 8123359eb26c89877bfa2fd29393f4c884e3f341 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 18 Feb 2016 17:25:04 +0000 Subject: [PATCH] Prefill placeholders for test message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you want to send yourself a test message from a template that has placeholders you can’t, at the moment. Rather than forcing you to upload a CSV, we should prefil the data, and then you only need to upload a CSV if you want to customise it. --- app/main/views/sms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/main/views/sms.py b/app/main/views/sms.py index 61a6f62cc..2889b62a1 100644 --- a/app/main/views/sms.py +++ b/app/main/views/sms.py @@ -104,10 +104,12 @@ def get_example_csv(service_id, template_id): @main.route("/services//sms/send//to-self", methods=['GET']) @login_required def send_sms_to_self(service_id, template_id): + template = templates_dao.get_service_template_or_404(service_id, template_id)['data'] + placeholders = list(Template(template).placeholders) output = io.StringIO() writer = csv.writer(output) - writer.writerow(['phone']) - writer.writerow([current_user.mobile_number]) + writer.writerow(['phone'] + placeholders) + writer.writerow([current_user.mobile_number] + ["test {}".format(header) for header in placeholders]) filedata = { 'file_name': 'Test run', 'data': output.getvalue().splitlines()