From c26840155496e76e2224b14068bff2e591622faf Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Wed, 15 Jun 2016 16:19:28 +0100 Subject: [PATCH] Updated for pr comments --- app/job/rest.py | 6 +++--- app/notifications/rest.py | 3 +++ app/template/rest.py | 5 +---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/job/rest.py b/app/job/rest.py index f4c090b19..fc3d49943 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -1,8 +1,8 @@ from flask import ( Blueprint, jsonify, - request, - current_app) + request +) from app.dao.jobs_dao import ( dao_create_job, @@ -43,7 +43,7 @@ def get_jobs_by_service(service_id): try: limit_days = int(request.args['limit_days']) except ValueError as e: - errors = {'error': ['{} is not an integer'.format(request.args['limit_days'])]} + errors = {'limit_days': ['{} is not an integer'.format(request.args['limit_days'])]} raise InvalidRequest(errors, status_code=400) else: limit_days = None diff --git a/app/notifications/rest.py b/app/notifications/rest.py index 933297e2f..ab5cf2168 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -292,6 +292,9 @@ def send_notification(notification_type): sms_template_notification_schema if notification_type == 'sms' else email_notification_schema ).load(request.get_json()) + if errors: + raise InvalidRequest(errors, status_code=400) + template = templates_dao.dao_get_template_by_id_and_service_id( template_id=notification['template'], service_id=service_id diff --git a/app/template/rest.py b/app/template/rest.py index 8ba246d34..dc285e9d1 100644 --- a/app/template/rest.py +++ b/app/template/rest.py @@ -29,10 +29,7 @@ register_errors(template) def _content_count_greater_than_limit(content, template_type): template = Template({'content': content, 'template_type': template_type}) - if template_type == 'sms' and \ - template.content_count > current_app.config.get('SMS_CHAR_COUNT_LIMIT'): - return True - return False + return template_type == 'sms' and template.content_count > current_app.config.get('SMS_CHAR_COUNT_LIMIT') @template.route('', methods=['POST'])