Add endpoint to return all letter contact blocks

Added the GET '/<uuid:service_id>/letter-contact' endpoint for returning
all letter contact blocks for a service.

Updated the DAO for service letter contacts to return the default letter
contact first.
This commit is contained in:
Katie Smith
2017-10-04 11:26:27 +01:00
parent 3ad0a43409
commit 1fa1ebb96f
4 changed files with 83 additions and 15 deletions

View File

@@ -1,3 +1,5 @@
from sqlalchemy import desc
from app import db
from app.dao.dao_utils import transactional
from app.errors import InvalidRequest
@@ -10,7 +12,8 @@ def dao_get_letter_contacts_by_service_id(service_id):
).filter(
ServiceLetterContact.service_id == service_id
).order_by(
ServiceLetterContact.created_at
desc(ServiceLetterContact.is_default),
desc(ServiceLetterContact.created_at)
).all()
return letter_contacts