mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
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:
@@ -1,3 +1,5 @@
|
||||
from notifications_utils.postal_address import PostalAddress
|
||||
|
||||
from app import create_random_identifier
|
||||
from app.models import LETTER_TYPE
|
||||
from app.notifications.process_notifications import persist_notification
|
||||
@@ -9,7 +11,7 @@ def create_letter_notification(letter_data, template, api_key, status, reply_to_
|
||||
template_version=template.version,
|
||||
template_postage=template.postage,
|
||||
# we only accept addresses_with_underscores from the API (from CSV we also accept dashes, spaces etc)
|
||||
recipient=letter_data['personalisation']['address_line_1'],
|
||||
recipient=PostalAddress.from_personalisation(letter_data['personalisation']).normalised,
|
||||
service=template.service,
|
||||
personalisation=letter_data['personalisation'],
|
||||
notification_type=LETTER_TYPE,
|
||||
|
||||
Reference in New Issue
Block a user