From 159d2ff6b23026313188cba8d575bd9222f3348e Mon Sep 17 00:00:00 2001 From: David McDonald Date: Fri, 1 Nov 2019 10:56:34 +0000 Subject: [PATCH] Add `form.validate_on_submit` for sending uploaded letter Decided it was better to call this then not. This does rely on the file_id not being corrupted so the file_id passed into `uploaded_letter_preview` is valid but am taking that risk given it should only change if a user is changing the form html. --- app/main/views/uploads.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/main/views/uploads.py b/app/main/views/uploads.py index 7fe967b9e..2ed2ae114 100644 --- a/app/main/views/uploads.py +++ b/app/main/views/uploads.py @@ -202,8 +202,11 @@ def send_uploaded_letter(service_id): abort(403) form = LetterUploadPostageForm() - file_id = form.file_id.data + + if not form.validate_on_submit(): + return uploaded_letter_preview(service_id, file_id) + postage = form.postage.data metadata = get_letter_metadata(service_id, file_id) filename = metadata.get('filename')