Only return non-archived email reply_to addresses

Updated the DAO methods which return a single email reply_to address and
all reply_to addresses to only return the non-archived addresses.

Changed the type of error that gets raised when using the Admin
interface to be BadRequestError instead of a SQLAlchemyError.
This commit is contained in:
Katie Smith
2018-04-25 12:19:12 +01:00
parent be28f2e2de
commit a57b2f50c2
6 changed files with 71 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
from sqlalchemy.orm.exc import NoResultFound
from app.config import QueueNames
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
@@ -89,7 +91,11 @@ def get_reply_to_text(notification_type, sender_id, service, template):
reply_to = None
if sender_id:
if notification_type == EMAIL_TYPE:
reply_to = dao_get_reply_to_by_id(service.id, sender_id).email_address
try:
reply_to = dao_get_reply_to_by_id(service.id, sender_id).email_address
except NoResultFound:
message = 'Reply to email address not found'
raise BadRequestError(message=message)
elif notification_type == SMS_TYPE:
reply_to = dao_get_service_sms_senders_by_id(service.id, sender_id).get_reply_to_text()
else: