Only return active SMS senders

Updated the DAO methods which return a single SMS sender and all SMS senders
to only return the non-archived senders. Changed the error raised in the Admin
interface from a SQLAlchemyError to a BadRequestError.
This commit is contained in:
Katie Smith
2018-04-25 14:23:00 +01:00
parent f810daa3c5
commit 663021e494
7 changed files with 77 additions and 19 deletions

View File

@@ -19,12 +19,16 @@ def insert_service_sms_sender(service, sms_sender):
def dao_get_service_sms_senders_by_id(service_id, service_sms_sender_id):
return ServiceSmsSender.query.filter_by(
id=service_sms_sender_id,
service_id=service_id
service_id=service_id,
archived=False
).one()
def dao_get_sms_senders_by_service_id(service_id):
return ServiceSmsSender.query.filter_by(service_id=service_id).order_by(desc(ServiceSmsSender.is_default)).all()
return ServiceSmsSender.query.filter_by(
service_id=service_id,
archived=False
).order_by(desc(ServiceSmsSender.is_default)).all()
@transactional