mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Move check for existing letter earlier in endpoint
In response to: [^1]. [^1]: https://github.com/alphagov/notifications-api/pull/3503#discussion_r848426047
This commit is contained in:
@@ -169,6 +169,10 @@ def send_pdf_letter_notification(service_id, post_data):
|
|||||||
allow_guest_list_recipients=False,
|
allow_guest_list_recipients=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# notification already exists e.g. if the user clicked send in different tabs
|
||||||
|
if get_notification_by_id(post_data['file_id']):
|
||||||
|
return {'id': str(post_data['file_id'])}
|
||||||
|
|
||||||
template = get_precompiled_letter_template(service.id)
|
template = get_precompiled_letter_template(service.id)
|
||||||
file_location = 'service-{}/{}.pdf'.format(service.id, post_data['file_id'])
|
file_location = 'service-{}/{}.pdf'.format(service.id, post_data['file_id'])
|
||||||
|
|
||||||
@@ -179,10 +183,6 @@ def send_pdf_letter_notification(service_id, post_data):
|
|||||||
post_data['file_id'], current_app.config['TRANSIENT_UPLOADED_LETTERS'])
|
post_data['file_id'], current_app.config['TRANSIENT_UPLOADED_LETTERS'])
|
||||||
)
|
)
|
||||||
|
|
||||||
# notification already exists e.g. if the user clicked send in different tabs
|
|
||||||
if get_notification_by_id(post_data['file_id']):
|
|
||||||
return {'id': str(post_data['file_id'])}
|
|
||||||
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# Getting the page count won't raise an error since admin has already checked the PDF is valid
|
# Getting the page count won't raise an error since admin has already checked the PDF is valid
|
||||||
|
|||||||
Reference in New Issue
Block a user