From c694dae9335920be7a7a97c30a1b0fda63a31c94 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Tue, 23 Feb 2016 12:35:28 +0000 Subject: [PATCH] Refactored to make email and sms template check the same --- app/notifications/rest.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/notifications/rest.py b/app/notifications/rest.py index 2b90355a2..3035066f1 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -49,9 +49,12 @@ def create_sms_notification(): if errors: return jsonify(result="error", message=errors), 400 - try: - templates_dao.get_model_templates(template_id=notification['template'], service_id=api_user['client']) - except NoResultFound: + template = templates_dao.dao_get_template_by_id_and_service_id( + template_id=notification['template'], + service_id=api_user['client'] + ) + + if not template: return jsonify(result="error", message={'template': ['Template not found']}), 400 service = services_dao.dao_fetch_service_by_id(api_user['client'])