Updated for pr comments

This commit is contained in:
Adam Shimali
2016-06-15 16:19:28 +01:00
parent b33312b855
commit c268401554
3 changed files with 7 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
from flask import ( from flask import (
Blueprint, Blueprint,
jsonify, jsonify,
request, request
current_app) )
from app.dao.jobs_dao import ( from app.dao.jobs_dao import (
dao_create_job, dao_create_job,
@@ -43,7 +43,7 @@ def get_jobs_by_service(service_id):
try: try:
limit_days = int(request.args['limit_days']) limit_days = int(request.args['limit_days'])
except ValueError as e: 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) raise InvalidRequest(errors, status_code=400)
else: else:
limit_days = None limit_days = None

View File

@@ -292,6 +292,9 @@ def send_notification(notification_type):
sms_template_notification_schema if notification_type == 'sms' else email_notification_schema sms_template_notification_schema if notification_type == 'sms' else email_notification_schema
).load(request.get_json()) ).load(request.get_json())
if errors:
raise InvalidRequest(errors, status_code=400)
template = templates_dao.dao_get_template_by_id_and_service_id( template = templates_dao.dao_get_template_by_id_and_service_id(
template_id=notification['template'], template_id=notification['template'],
service_id=service_id service_id=service_id

View File

@@ -29,10 +29,7 @@ register_errors(template)
def _content_count_greater_than_limit(content, template_type): def _content_count_greater_than_limit(content, template_type):
template = Template({'content': content, 'template_type': template_type}) template = Template({'content': content, 'template_type': template_type})
if template_type == 'sms' and \ return template_type == 'sms' and template.content_count > current_app.config.get('SMS_CHAR_COUNT_LIMIT')
template.content_count > current_app.config.get('SMS_CHAR_COUNT_LIMIT'):
return True
return False
@template.route('', methods=['POST']) @template.route('', methods=['POST'])