From fcaed04918fe9b416e9d762996cab093249af1a1 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Mon, 15 Feb 2016 15:02:19 +0000 Subject: [PATCH] Fix validation of template for service. When the delivery app creates the sms on behalf of the service, the validation was failing. --- app/schemas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/schemas.py b/app/schemas.py index 050e35d48..3a9ab37e3 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -122,7 +122,9 @@ class SmsTemplateNotificationSchema(SmsNotificationSchema): raise ValidationError('Invalid phone number for restricted service', 'restricted') # Assert the template is valid for the service which made the request. service = api_user['client'] - if (service != current_app.config.get('ADMIN_CLIENT_USER_NAME') and + admin_users = [current_app.config.get('ADMIN_CLIENT_USER_NAME'), + current_app.config.get('DELIVERY_CLIENT_USER_NAME')] + if (service not in admin_users and template.service != models.Service.query.filter_by(id=service).first()): raise ValidationError('Invalid template', 'restricted')