Refactored post template

This commit is contained in:
Ken Tsang
2017-04-11 16:37:30 +01:00
parent 7c0aeca66e
commit ccd25382ea
2 changed files with 6 additions and 7 deletions

View File

@@ -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

View File

@@ -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
}