Don’t store info about bad uploads in session

Because we now[1] store info about each file upload separately in the
session the session isn’t overridden every time you upload a file. This
is good because you can do multiple file uploads idempotently.

Generally we are cleaning up after ourselves because we pop anything to
do with that upload from the session. However there is an edge case: if
you never send the file then the info about the file stays in the
session in perpetuity[2]. This is generally happening when people are
uploading files that are impossible to send, ie ones that have errors.

So this commit makes two changes:

1. remove info about a file upload from the session as soon as we know
   that it contains errors
2. `POST` reuploads to the same endpoint as initial uploads because
   otherwise we need to keep info about bad uploads in the session,
   which would prevent us from doing 1.

1. https://github.com/alphagov/notifications-admin/pull/1968
2. or at least until the session is cleared by the user logging out
This commit is contained in:
Chris Hill-Scott
2018-03-29 11:56:53 +01:00
parent a3374f32d8
commit e74d261ec3
5 changed files with 46 additions and 48 deletions

View File

@@ -135,7 +135,11 @@
{% if request.args.from_test %}
<a href="{{ back_link }}" class="page-footer-back-link">Back</a>
{% else %}
{{file_upload(form.file, button_text='Re-upload your file')}}
{{ file_upload(
form.file,
action=url_for('.send_messages', service_id=current_service.id, template_id=template.id),
button_text='Re-upload your file'
) }}
{% endif %}
</div>
<a href="#content" class="back-to-top-link">Back to top</a>