mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-15 19:01:04 -04:00
Merge pull request #113 from alphagov/real-templates
Use real templates when sending text messages
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
templates = [
|
||||
{
|
||||
'type': 'sms',
|
||||
'name': 'Confirmation with details Jan 2016',
|
||||
'body': '((name)), we’ve received your ((thing)). We’ll contact you again within 1 week.'
|
||||
},
|
||||
{
|
||||
'type': 'sms',
|
||||
'name': 'Confirmation Jan 2016',
|
||||
'body': 'We’ve received your payment. We’ll contact you again within 1 week.'
|
||||
}
|
||||
]
|
||||
@@ -24,12 +24,7 @@ from app.main.uploader import (
|
||||
s3upload,
|
||||
s3download
|
||||
)
|
||||
|
||||
from ._templates import templates
|
||||
|
||||
sms_templates = [
|
||||
template for template in templates if template['type'] == 'sms'
|
||||
]
|
||||
from app.main.dao import templates_dao
|
||||
|
||||
|
||||
@main.route("/services/<int:service_id>/sms/send", methods=['GET', 'POST'])
|
||||
@@ -51,8 +46,16 @@ def send_sms(service_id):
|
||||
flash(str(e))
|
||||
return redirect(url_for('.send_sms', service_id=service_id))
|
||||
|
||||
try:
|
||||
templates = templates_dao.get_service_templates(service_id)['data']
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
abort(404)
|
||||
else:
|
||||
raise e
|
||||
|
||||
return render_template('views/send-sms.html',
|
||||
message_templates=sms_templates,
|
||||
templates=templates,
|
||||
form=form,
|
||||
service_id=service_id)
|
||||
|
||||
@@ -69,7 +72,9 @@ def check_sms(service_id, upload_id):
|
||||
'views/check-sms.html',
|
||||
upload_result=upload_result,
|
||||
filename='someupload_file_name.csv',
|
||||
message_template=sms_templates[0]['body'],
|
||||
message_template='''
|
||||
((name)), we’ve received your ((thing)). We’ll contact you again within 1 week.
|
||||
''',
|
||||
service_id=service_id
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</h3>
|
||||
{% endif %}
|
||||
{% if input_name %}
|
||||
<input class="sms-message-picker" type="radio" id="{{ input_name }}-{{ input_index }}" name="{{ input_name }}" />
|
||||
<input class="sms-message-picker" type="radio" id="{{ input_name }}-{{ input_index }}" name="{{ input_name }}" value="{{ input_index }}" />
|
||||
{% endif %}
|
||||
<div class="sms-message-wrapper{% if input_name %}-with-radio{% endif %}">
|
||||
{{ body|placeholders }}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
<fieldset class='form-group'>
|
||||
<legend class="heading-medium">1. Choose text message template</legend>
|
||||
{% for template in message_templates %}
|
||||
{% for template in templates %}
|
||||
{{ sms_message(
|
||||
template.body, name=template.name, input_name='template', input_index=loop.index
|
||||
template.content, name=template.name, input_name='template', input_index=template.id
|
||||
) }}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user