Save whole letter address into the to field

At the moment we’re not consistent:

Precompiled (API and one-off):
`to` has the whole address
`normalised_to` has nothing

Templated (API, CSV and one off):
`to` has the first line of the address
`normalised_to` has nothing

This commit makes us consistently store the whole address in the `to`
field. We think that people might want to search by postcode, not just
first line of the address.

This commit also starts to populate the normalised_to field with the
address lowercased and with all spaces removed, to make it easier to
search on.
This commit is contained in:
Chris Hill-Scott
2020-04-22 10:06:25 +01:00
parent 7897ae70ce
commit 9047b273da
4 changed files with 46 additions and 12 deletions

View File

@@ -345,7 +345,7 @@ def save_letter(
# we store the recipient as just the first item of the person's address
recipient = PostalAddress.from_personalisation(
Columns(notification['personalisation'])
).normalised_lines[0]
).normalised
service = dao_fetch_service_by_id(service_id)
template = dao_get_template_by_id(notification['template'], version=notification['template_version'])