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

@@ -13,7 +13,10 @@ from app.encryption import (
check_hash
)
from app import db
from app import (
db,
encryption
)
from app.history_meta import Versioned
@@ -347,6 +350,18 @@ class Notification(db.Model):
status = db.Column(
db.Enum(*NOTIFICATION_STATUS_TYPES, name='notify_status_types'), nullable=False, default='sending')
reference = db.Column(db.String, nullable=True, index=True)
_personalisation = db.Column(db.String, nullable=True)
@property
def personalisation(self):
if self._personalisation:
return encryption.decrypt(self._personalisation)
return None
@personalisation.setter
def personalisation(self, personalisation):
if personalisation:
self._personalisation = encryption.encrypt(personalisation)
INVITED_USER_STATUS_TYPES = ['pending', 'accepted', 'cancelled']