notifications_utils Template constructor accepts None for

personalisation data therefore None check not needed.

If personalisation is None in in db it will get passed through to
template which returns content.
This commit is contained in:
Adam Shimali
2016-06-23 15:35:35 +01:00
parent 3423c0c44d
commit 0e2e99f64e

View File

@@ -259,23 +259,17 @@ class NotificationStatusSchema(BaseSchema):
@pre_dump
def handle_personalisation_property(self, in_data):
if in_data.personalisation:
self.personalisation = in_data.personalisation
self.personalisation = in_data.personalisation
return in_data
@post_dump
def handle_template_merge(self, in_data):
if in_data.get('personalisation'):
from notifications_utils.template import Template
template = Template(in_data['template'], in_data['personalisation'])
in_data['body'] = template.replaced
if in_data['template']['template_type'] == 'email':
in_data['subject'] = template.replaced_subject
in_data.pop('personalisation', None)
else:
in_data['body'] = in_data['template']['content']
if in_data['template']['template_type'] == 'email':
in_data['subject'] = in_data['template']['subject']
from notifications_utils.template import Template
template = Template(in_data['template'], in_data['personalisation'])
in_data['body'] = template.replaced
if in_data['template']['template_type'] == 'email':
in_data['subject'] = template.replaced_subject
in_data.pop('personalisation', None)
in_data['template'].pop('content', None)
in_data['template'].pop('subject', None)
return in_data