mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Show the first line of the address from the to field.
Now persisting the address to the "to" field of the Notification, after the notification has been validated. If the letter is pending validation, then "Checking..." will appear as the identifier for the letter. If the letter has passed validation, then the first line of the address (now persisted in the "to" field) will be displayed, with the client reference underneath. If the letter has failed validation the "Provided as PDF" will show be displayed, which is now the initial value of the "to" field.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import json
|
||||
import urllib
|
||||
|
||||
from boto3 import resource
|
||||
from flask import current_app
|
||||
from notifications_utils.s3 import s3upload as utils_s3upload
|
||||
from notifications_utils.sanitise_text import SanitiseASCII
|
||||
|
||||
|
||||
def get_transient_letter_file_location(service_id, upload_id):
|
||||
@@ -31,7 +31,7 @@ def upload_letter_to_s3(
|
||||
if invalid_pages:
|
||||
metadata['invalid_pages'] = json.dumps(invalid_pages)
|
||||
if recipient:
|
||||
metadata['recipient'] = format_recipient(recipient)
|
||||
metadata['recipient'] = urllib.parse.quote(recipient)
|
||||
|
||||
utils_s3upload(
|
||||
filedata=data,
|
||||
@@ -59,20 +59,3 @@ def get_letter_metadata(service_id, file_id):
|
||||
s3_object = s3.Object(current_app.config['TRANSIENT_UPLOADED_LETTERS'], file_location).get()
|
||||
|
||||
return s3_object['Metadata']
|
||||
|
||||
|
||||
def format_recipient(address):
|
||||
'''
|
||||
To format the recipient we need to:
|
||||
- remove new line characters
|
||||
- remove whitespace around the lines
|
||||
- join the address lines, separated by a comma
|
||||
- convert the string to ASCII (S3 metadata must be stored as ASCII)
|
||||
'''
|
||||
stripped_address_lines_no_trailing_commas = [
|
||||
line.lstrip().rstrip(' ,')
|
||||
for line in address.splitlines() if line
|
||||
]
|
||||
one_line_address = ', '.join(stripped_address_lines_no_trailing_commas)
|
||||
|
||||
return SanitiseASCII.encode(one_line_address)
|
||||
|
||||
Reference in New Issue
Block a user