Use new properties of utils Templates

We’ve added some new properties to the templates in utils that we can
use instead of doing weird things like
`WithSubjectTemplate.__str__(another_instance)`
This commit is contained in:
Chris Hill-Scott
2020-04-13 13:48:23 +01:00
parent ee25dc79e4
commit 5ddb5a75da
10 changed files with 28 additions and 57 deletions

View File

@@ -4,7 +4,6 @@ from flask import (
request,
current_app
)
from notifications_utils.template import WithSubjectTemplate
from app import api_user, authenticated_service
from app.config import QueueNames
@@ -151,13 +150,11 @@ def send_notification(notification_type):
def get_notification_return_data(notification_id, notification, template):
output = {
'template_version': notification['template_version'],
'notification': {'id': notification_id}
'notification': {'id': notification_id},
'body': template.content_with_placeholders_filled_in,
}
if template.template_type == SMS_TYPE:
output['body'] = str(template)
else:
output['body'] = WithSubjectTemplate.__str__(template)
if hasattr(template, 'subject'):
output['subject'] = template.subject
return output