mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Refactored code to personalise subject
This commit is contained in:
@@ -6,6 +6,7 @@ from werkzeug.exceptions import abort
|
||||
|
||||
from app import api_user
|
||||
from app.dao import templates_dao
|
||||
from app.models import SMS_TYPE
|
||||
from app.schema_validation import validate
|
||||
from app.utils import get_template_instance
|
||||
from app.v2.errors import BadRequestError
|
||||
@@ -16,6 +17,9 @@ from app.v2.template.template_schemas import post_template_preview_request, crea
|
||||
@v2_template_blueprint.route("/<template_id>/preview", methods=['POST'])
|
||||
def post_template_preview(template_id):
|
||||
_data = request.get_json()
|
||||
if _data is None:
|
||||
_data = {}
|
||||
|
||||
_data['id'] = template_id
|
||||
|
||||
data = validate(_data, post_template_preview_request)
|
||||
@@ -28,7 +32,10 @@ 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))
|
||||
|
||||
return jsonify(resp), 200
|
||||
|
||||
Reference in New Issue
Block a user