mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Refactored post template
This commit is contained in:
@@ -29,11 +29,8 @@ def post_template_preview(template_id):
|
|||||||
|
|
||||||
check_placeholders(template_object)
|
check_placeholders(template_object)
|
||||||
|
|
||||||
subject = template_object.subject if template.template_type != SMS_TYPE else None
|
|
||||||
|
|
||||||
resp = create_post_template_preview_response(template=template,
|
resp = create_post_template_preview_response(template=template,
|
||||||
subject=subject,
|
template_object=template_object)
|
||||||
body=str(template_object))
|
|
||||||
|
|
||||||
return jsonify(resp), 200
|
return jsonify(resp), 200
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
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 {
|
return {
|
||||||
"id": template.id,
|
"id": template.id,
|
||||||
"type": template.template_type,
|
"type": template.template_type,
|
||||||
"version": template.version,
|
"version": template.version,
|
||||||
"body": body,
|
"body": str(template_object),
|
||||||
"subject": subject
|
"subject": subject
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user