mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 17:38:50 -04:00
Tell template preview whether a letter can be sent internationally
If a service has permission to send international letters then the admin app should tell template preview, so that template preview knows what rules to apply when it’s validating the address of the letter. We don’t need to wait for template preview to start looking at this query string argument – it will just ignore it for now.
This commit is contained in:
@@ -115,7 +115,12 @@ def upload_letter(service_id):
|
||||
file_location = get_transient_letter_file_location(service_id, upload_id)
|
||||
|
||||
try:
|
||||
response = sanitise_letter(BytesIO(pdf_file_bytes))
|
||||
response = sanitise_letter(
|
||||
BytesIO(pdf_file_bytes),
|
||||
allow_international_letters=current_service.has_permission(
|
||||
'international_letters'
|
||||
),
|
||||
)
|
||||
response.raise_for_status()
|
||||
except RequestException as ex:
|
||||
if ex.response is not None and ex.response.status_code == 400:
|
||||
|
||||
@@ -94,9 +94,12 @@ def get_page_count_for_letter(template, values=None):
|
||||
return page_count
|
||||
|
||||
|
||||
def sanitise_letter(pdf_file):
|
||||
def sanitise_letter(pdf_file, *, allow_international_letters):
|
||||
return requests.post(
|
||||
'{}/precompiled/sanitise'.format(current_app.config['TEMPLATE_PREVIEW_API_HOST']),
|
||||
'{}/precompiled/sanitise?allow_international_letters={}'.format(
|
||||
current_app.config['TEMPLATE_PREVIEW_API_HOST'],
|
||||
'true' if allow_international_letters else 'false',
|
||||
),
|
||||
data=pdf_file,
|
||||
headers={'Authorization': 'Token {}'.format(current_app.config['TEMPLATE_PREVIEW_API_KEY'])}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user