From 0e2e99f64e8aeb7df5b7ca2e25cf7c640ecb2840 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Thu, 23 Jun 2016 15:35:35 +0100 Subject: [PATCH] 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. --- app/schemas.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/schemas.py b/app/schemas.py index bd45dca22..0a7eab8d1 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -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