Change get_bucket_name_and_prefix_for_notification to use created_at

The `get_bucket_name_and_prefix_for_notification` function was looking
at the `sent_at` or `updated_at` at time of a notification to see which
bucket it was in. Precompiled letters sent through the admin app don't
have either of these times - they only have a `created_at` time, so this
lets the function check `created_at` time too.
This commit is contained in:
Katie Smith
2019-09-09 14:18:08 +01:00
parent 8347b86b44
commit 190119f4fe
2 changed files with 17 additions and 1 deletions

View File

@@ -63,8 +63,10 @@ def get_bucket_name_and_prefix_for_notification(notification):
bucket_name = current_app.config['LETTERS_PDF_BUCKET_NAME']
if notification.sent_at:
folder = "{}/".format(notification.sent_at.date())
else:
elif notification.updated_at:
folder = get_folder_name(notification.updated_at, False)
else:
folder = get_folder_name(notification.created_at, False)
upload_file_name = PRECOMPILED_BUCKET_PREFIX.format(
folder=folder,