mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-26 08:09:51 -04:00
Prefill placeholders for test message
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.
This commit is contained in:
@@ -104,10 +104,12 @@ def get_example_csv(service_id, template_id):
|
||||
@main.route("/services/<service_id>/sms/send/<template_id>/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()
|
||||
|
||||
Reference in New Issue
Block a user