mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Refactor to split s3_client.py into multiple files
Separated s3_client.py into 3 files - for logos, CSV files and the MOU. This helps to keep things clearer now that we need to add lots more logo functions for letters.
This commit is contained in:
24
app/s3_client/s3_mou_client.py
Normal file
24
app/s3_client/s3_mou_client.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import botocore
|
||||
from flask import current_app
|
||||
|
||||
from app.s3_client.s3_logo_client import get_s3_object
|
||||
|
||||
|
||||
def get_mou(organisation_is_crown):
|
||||
bucket = current_app.config['MOU_BUCKET_NAME']
|
||||
filename = 'crown.pdf' if organisation_is_crown else 'non-crown.pdf'
|
||||
attachment_filename = 'GOV.UK Notify data sharing and financial agreement{}.pdf'.format(
|
||||
'' if organisation_is_crown else ' (non-crown)'
|
||||
)
|
||||
try:
|
||||
key = get_s3_object(bucket, filename)
|
||||
return {
|
||||
'filename_or_fp': key.get()['Body'],
|
||||
'attachment_filename': attachment_filename,
|
||||
'as_attachment': True,
|
||||
}
|
||||
except botocore.exceptions.ClientError as exception:
|
||||
current_app.logger.error("Unable to download s3 file {}/{}".format(
|
||||
bucket, filename
|
||||
))
|
||||
raise exception
|
||||
Reference in New Issue
Block a user