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

@@ -10,7 +10,8 @@ def dao_get_reply_to_by_service_id(service_id):
reply_to = db.session.query(
ServiceEmailReplyTo
).filter(
ServiceEmailReplyTo.service_id == service_id
ServiceEmailReplyTo.service_id == service_id,
ServiceEmailReplyTo.archived == False # noqa
).order_by(desc(ServiceEmailReplyTo.is_default), desc(ServiceEmailReplyTo.created_at)).all()
return reply_to
@@ -20,7 +21,8 @@ def dao_get_reply_to_by_id(service_id, reply_to_id):
ServiceEmailReplyTo
).filter(
ServiceEmailReplyTo.service_id == service_id,
ServiceEmailReplyTo.id == reply_to_id
ServiceEmailReplyTo.id == reply_to_id,
ServiceEmailReplyTo.archived == False # noqa
).order_by(ServiceEmailReplyTo.created_at).one()
return reply_to