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

@@ -109,6 +109,7 @@ def persist_notification(
notification.normalised_to = format_email_address(notification.to)
elif notification_type == LETTER_TYPE:
notification.postage = postage or template_postage
notification.normalised_to = ''.join(notification.to.split()).lower()
# if simulated create a Notification model to return but do not persist the Notification to the dB
if not simulated: