If the job is for letters do not add the sender_id.

How this happens: a user starts to send a letter job, then in another tab starts a SMS
or email job, the sender_id is set in the session. Then the user goes
back to the letter job tab and creates the job. The sender_id is set in
the metadata of the csv file, and causes an exception when trying to persist
the letter notification.

This PR adds a check to ensure the sender_id is not set for letter jobs.

This will catch a small use case where the user has multiple tabs open
and has started sending an SMS or email job, then tries to send a letter
job.
This commit is contained in:
Rebecca Law
2021-04-15 13:51:48 +01:00
parent 2871d4cb04
commit ac0b8ed95c
2 changed files with 49 additions and 1 deletions

View File

@@ -742,7 +742,8 @@ def check_messages(service_id, template_id, upload_id, row_index=2):
'original_file_name': data.get('original_file_name', ''),
}
if session.get('sender_id'):
if session.get('sender_id') and data['template'].template_type != 'letter':
# sender_id is not an option for sending letters.
metadata_kwargs['sender_id'] = session['sender_id']
set_metadata_on_csv_upload(service_id, upload_id, **metadata_kwargs)