Fix bug which prevented viewing an email job

The template for viewing a job was not getting all the variables it needed in
order to display an email template. Hadn’t noticed this before, because email
templates require more variables than SMS templates.

This commit fixes that bug.
This commit is contained in:
Chris Hill-Scott
2016-03-09 12:18:11 +00:00
parent 2dbfff4730
commit b93a1e89c8
4 changed files with 14 additions and 10 deletions

View File

@@ -17,6 +17,7 @@
@include core-19;
border-bottom: 0;
border-top: 1px solid $border-colour;
vertical-align: top;
}
th {

View File

@@ -40,6 +40,7 @@ def view_job(service_id, job_id):
service = services_dao.get_service_by_id_or_404(service_id)
try:
job = job_api_client.get_job(service_id, job_id)['data']
template = templates_dao.get_service_template_or_404(service_id, job['template'])['data']
notifications = notification_api_client.get_notifications_for_service(service_id, job_id)
finished = job['status'] == 'finished'
return render_template(
@@ -55,11 +56,11 @@ def view_job(service_id, job_id):
finished_at=job['updated_at'] if finished else None,
uploaded_file_name=job['original_file_name'],
template=Template(
templates_dao.get_service_template_or_404(service_id, job['template'])['data'],
prefix=service['name']
template,
prefix=service['name'] if template['template_type'] == 'sms' else ''
),
service_id=service_id,
from_name=service['name'],
service=service,
job_id=job_id
)
except HTTPError as e:

View File

@@ -203,12 +203,14 @@ def check_messages(service_id, upload_id):
if not contents:
flash('There was a problem reading your upload file')
template = templates_dao.get_service_template_or_404(
service_id,
session['upload_data'].get('template_id')
)['data']
template = Template(
templates_dao.get_service_template_or_404(
service_id,
session['upload_data'].get('template_id')
)['data'],
prefix=service['name']
template,
prefix=service['name'] if template['template_type'] == 'sms' else ''
)
recipients = RecipientCSV(

View File

@@ -24,9 +24,9 @@
{% elif 'email' == template.template_type %}
{{ email_message(
template.subject,
template,
template.formatted_as_markup,
from_address='{}@notifications.service.gov.uk'.format(service.email_from),
from_name=from_name
from_name=service.name
)}}
{% endif %}