Only return non-archived letter contact blocks

Changed DAO functions which return one letter contact block and all
letter contact blocks for a service to only return non-archived ones.
This commit is contained in:
Katie Smith
2018-04-25 12:33:10 +01:00
parent a57b2f50c2
commit f810daa3c5
3 changed files with 35 additions and 5 deletions

View File

@@ -10,7 +10,8 @@ def dao_get_letter_contacts_by_service_id(service_id):
letter_contacts = db.session.query(
ServiceLetterContact
).filter(
ServiceLetterContact.service_id == service_id
ServiceLetterContact.service_id == service_id,
ServiceLetterContact.archived == False # noqa
).order_by(
desc(ServiceLetterContact.is_default),
desc(ServiceLetterContact.created_at)
@@ -24,7 +25,8 @@ def dao_get_letter_contact_by_id(service_id, letter_contact_id):
ServiceLetterContact
).filter(
ServiceLetterContact.service_id == service_id,
ServiceLetterContact.id == letter_contact_id
ServiceLetterContact.id == letter_contact_id,
ServiceLetterContact.archived == False # noqa
).one()
return letter_contact