Template and personalisation content is now merged and returned with

notifications, when retrieved by notification id, or service id (i.e.
all notifications for service).

There is a new element returned at top level of notification json called
body, which is the template content merged with personalisation. This
is consistent with api to endpoint to create notification which returns
what was sent as 'body' in json response.

Merging of template with personalisation is done in the
NotificationStatusSchema.

Personalisation data in encrypted before storing in db.
This commit is contained in:
Adam Shimali
2016-06-20 16:23:56 +01:00
parent 561b02208d
commit 731bb19a9c
8 changed files with 210 additions and 24 deletions

View File

@@ -18,7 +18,6 @@ from notifications_utils.template import Template
from notifications_utils.recipients import (
RecipientCSV,
validate_and_format_phone_number,
allowed_to_send_to
)
@@ -233,7 +232,8 @@ def send_sms(self, service_id, notification_id, encrypted_notification, created_
job_id=notification.get('job', None),
job_row_number=notification.get('row_number', None),
status='sending',
created_at=datetime.strptime(created_at, DATETIME_FORMAT)
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
personalisation=notification.get('personalisation')
)
dao_create_notification(notification_db_object, TEMPLATE_TYPE_SMS)
@@ -277,7 +277,8 @@ def send_email(service_id, notification_id, encrypted_notification, created_at,
status='sending',
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
sent_at=sent_at,
sent_by=provider.get_name()
sent_by=provider.get_name(),
personalisation=notification.get('personalisation')
)
dao_create_notification(notification_db_object, TEMPLATE_TYPE_EMAIL)