fix placeholders not appearing in email subject

it now switches utils.template.Template type, since the base Template
type now no longer has a subject attribute.

updated test case to use `sample_email_template_with_placeholders`
instead of `sample_email_template`
This commit is contained in:
Leo Hemsted
2016-12-22 14:40:33 +00:00
parent 6bf024569a
commit 3ed97151ee
3 changed files with 25 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ from flask import current_app
from notifications_utils.recipients import (
RecipientCSV
)
from notifications_utils.template import Template
from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate
from sqlalchemy.exc import SQLAlchemyError
from app import (
create_uuid,
@@ -48,9 +48,10 @@ def process_job(job_id):
job.job_status = 'in progress'
dao_update_job(job)
template = Template(
dao_get_template_by_id(job.template_id, job.template_version).__dict__
)
db_template = dao_get_template_by_id(job.template_id, job.template_version)
TemplateClass = SMSMessageTemplate if db_template.template_type == SMS_TYPE else WithSubjectTemplate
template = TemplateClass(db_template.__dict__)
for row_number, recipient, personalisation in RecipientCSV(
s3.get_job_from_s3(str(service.id), str(job_id)),