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

View File

@@ -197,21 +197,25 @@ def check_messages(service_id, upload_id):
form=CsvUploadForm()
)
elif request.method == 'POST':
original_file_name = upload_data.get('original_file_name')
notification_count = upload_data.get('notification_count')
session.pop('upload_data')
try:
job_api_client.create_job(upload_id, service_id, template_id, original_file_name, notification_count)
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
if request.files:
# The csv was invalid, validate the csv again
return send_messages(service_id, template_id)
else:
original_file_name = upload_data.get('original_file_name')
notification_count = upload_data.get('notification_count')
session.pop('upload_data')
try:
job_api_client.create_job(upload_id, service_id, template_id, original_file_name, notification_count)
except HTTPError as e:
if e.status_code == 404:
abort(404)
else:
raise e
flash('Weve started sending your messages', 'default_with_tick')
return redirect(
url_for('main.view_job', service_id=service_id, job_id=upload_id)
)
flash('Weve started sending your messages', 'default_with_tick')
return redirect(
url_for('main.view_job', service_id=service_id, job_id=upload_id)
)
def _get_filedata(file):