If the file was invalid and Upload a CSV file was clicked, the job was created, then the send would fail when sending the file, trying to replace a placeholder that didn't exist.

This commit calls send_messages again if the files exist on the request.
This commit is contained in:
Rebecca Law
2016-03-03 11:14:43 +00:00
parent 2c38fa7141
commit 584fac9683
+18 -14
View File
@@ -197,21 +197,25 @@ def check_messages(service_id, upload_id):
form=CsvUploadForm() form=CsvUploadForm()
) )
elif request.method == 'POST': elif request.method == 'POST':
original_file_name = upload_data.get('original_file_name') if request.files:
notification_count = upload_data.get('notification_count') # The csv was invalid, validate the csv again
session.pop('upload_data') return send_messages(service_id, template_id)
try: else:
job_api_client.create_job(upload_id, service_id, template_id, original_file_name, notification_count) original_file_name = upload_data.get('original_file_name')
except HTTPError as e: notification_count = upload_data.get('notification_count')
if e.status_code == 404: session.pop('upload_data')
abort(404) try:
else: job_api_client.create_job(upload_id, service_id, template_id, original_file_name, notification_count)
raise e except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
flash('Weve started sending your messages', 'default_with_tick') flash('Weve started sending your messages', 'default_with_tick')
return redirect( return redirect(
url_for('main.view_job', service_id=service_id, job_id=upload_id) url_for('main.view_job', service_id=service_id, job_id=upload_id)
) )
def _get_filedata(file): def _get_filedata(file):