mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-14 23:07:49 -04:00
Merge pull request #2692 from alphagov/put-address-in-to-field-for-precompiled
Put address in to field for precompiled
This commit is contained in:
@@ -255,7 +255,8 @@ def process_virus_scan_passed(self, filename):
|
||||
update_letter_pdf_status(
|
||||
reference=reference,
|
||||
status=NOTIFICATION_DELIVERED if is_test_key else NOTIFICATION_CREATED,
|
||||
billable_units=billable_units
|
||||
billable_units=billable_units,
|
||||
recipient_address=sanitise_response.get("recipient_address")
|
||||
)
|
||||
scan_pdf_object.delete()
|
||||
except BotoClientError:
|
||||
@@ -474,14 +475,14 @@ def process_virus_scan_error(filename):
|
||||
raise error
|
||||
|
||||
|
||||
def update_letter_pdf_status(reference, status, billable_units):
|
||||
def update_letter_pdf_status(reference, status, billable_units, recipient_address=None):
|
||||
|
||||
update_dict = {'status': status, 'billable_units': billable_units, 'updated_at': datetime.utcnow()}
|
||||
if recipient_address:
|
||||
update_dict['to'] = recipient_address
|
||||
return dao_update_notifications_by_reference(
|
||||
references=[reference],
|
||||
update_dict={
|
||||
'status': status,
|
||||
'billable_units': billable_units,
|
||||
'updated_at': datetime.utcnow()
|
||||
})[0]
|
||||
update_dict=update_dict)[0]
|
||||
|
||||
|
||||
def replay_letters_in_error(filename=None):
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import urllib
|
||||
|
||||
from flask import current_app
|
||||
from notifications_utils.s3 import S3ObjectNotFound, s3download as utils_s3download
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
@@ -141,7 +143,7 @@ def send_pdf_letter_notification(service_id, post_data):
|
||||
check_service_over_daily_message_limit(KEY_TYPE_NORMAL, service)
|
||||
validate_created_by(service, post_data['created_by'])
|
||||
validate_and_format_recipient(
|
||||
send_to=post_data['filename'],
|
||||
send_to=post_data['recipient_address'],
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
service=service,
|
||||
notification_type=LETTER_TYPE,
|
||||
@@ -172,7 +174,7 @@ def send_pdf_letter_notification(service_id, post_data):
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
template_postage=template.postage,
|
||||
recipient=post_data['filename'],
|
||||
recipient=urllib.parse.unquote(post_data['recipient_address']),
|
||||
service=service,
|
||||
personalisation=personalisation,
|
||||
notification_type=LETTER_TYPE,
|
||||
|
||||
@@ -8,6 +8,7 @@ send_pdf_letter_request = {
|
||||
"filename": {"type": "string"},
|
||||
"created_by": {"type": "string"},
|
||||
"file_id": {"type": "string"},
|
||||
"recipient_address": {"type": "string"}
|
||||
},
|
||||
"required": ["postage", "filename", "created_by", "file_id"]
|
||||
"required": ["postage", "filename", "created_by", "file_id", "recipient_address"]
|
||||
}
|
||||
|
||||
@@ -75,8 +75,10 @@ def post_precompiled_letter_notification():
|
||||
|
||||
template = get_precompiled_letter_template(authenticated_service.id)
|
||||
|
||||
# For precompiled letters the to field will be set to Provided as PDF until the validation passes,
|
||||
# then the address of the letter will be set as the to field
|
||||
form['personalisation'] = {
|
||||
'address_line_1': form['reference']
|
||||
'address_line_1': 'Provided as PDF'
|
||||
}
|
||||
|
||||
reply_to = get_reply_to_text(LETTER_TYPE, form, template)
|
||||
|
||||
Reference in New Issue
Block a user