mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Refactor process_letter_notification to make the code easier to read.
- Separated the logic of precompiled and template letters. - Remove the check for research mode, research mode is not relevant to api calls. The test key is used for testing. Refactor upload_pdf_letter to accept a precompile boolean to save a query to template.
This commit is contained in:
@@ -64,16 +64,16 @@ def get_reference_from_filename(filename):
|
||||
return filename_parts[1]
|
||||
|
||||
|
||||
def upload_letter_pdf(notification, pdf_data):
|
||||
def upload_letter_pdf(notification, pdf_data, precompiled=False):
|
||||
current_app.logger.info("PDF Letter {} reference {} created at {}, {} bytes".format(
|
||||
notification.id, notification.reference, notification.created_at, len(pdf_data)))
|
||||
|
||||
upload_file_name = get_letter_pdf_filename(
|
||||
notification.reference,
|
||||
notification.service.crown,
|
||||
is_scan_letter=notification.template.is_precompiled_letter)
|
||||
is_scan_letter=precompiled)
|
||||
|
||||
if notification.template.is_precompiled_letter:
|
||||
if precompiled:
|
||||
bucket_name = current_app.config['LETTERS_SCAN_BUCKET_NAME']
|
||||
else:
|
||||
bucket_name = current_app.config['LETTERS_PDF_BUCKET_NAME']
|
||||
|
||||
Reference in New Issue
Block a user