From ccd25382eae448df8e11e912483030d98ddc5325 Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Tue, 11 Apr 2017 16:37:30 +0100 Subject: [PATCH] Refactored post template --- app/v2/template/post_template.py | 5 +---- app/v2/template/template_schemas.py | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/v2/template/post_template.py b/app/v2/template/post_template.py index ae9b16002..3da768ef1 100644 --- a/app/v2/template/post_template.py +++ b/app/v2/template/post_template.py @@ -29,11 +29,8 @@ def post_template_preview(template_id): check_placeholders(template_object) - subject = template_object.subject if template.template_type != SMS_TYPE else None - resp = create_post_template_preview_response(template=template, - subject=subject, - body=str(template_object)) + template_object=template_object) return jsonify(resp), 200 diff --git a/app/v2/template/template_schemas.py b/app/v2/template/template_schemas.py index dac2c4cde..6f08d9cfc 100644 --- a/app/v2/template/template_schemas.py +++ b/app/v2/template/template_schemas.py @@ -1,4 +1,4 @@ -from app.models import TEMPLATE_TYPES +from app.models import SMS_TYPE, TEMPLATE_TYPES from app.schema_validation.definitions import uuid, personalisation @@ -68,11 +68,13 @@ post_template_preview_response = { } -def create_post_template_preview_response(template, subject, body): +def create_post_template_preview_response(template, template_object): + subject = template_object.subject if template.template_type != SMS_TYPE else None + return { "id": template.id, "type": template.template_type, "version": template.version, - "body": body, + "body": str(template_object), "subject": subject }