Read job metadata from S3 metadata

All of our uploads now have the metadata about the job set on them in
S3. So this commit moves to using that metadata, if it’s there, instead
of the data in the body of the post request.

The aim of this is to stop the admin app having to post this data, which
means that it won’t have to keep this data in the session for the
while doing the file upload flow.
This commit is contained in:
Chris Hill-Scott
2018-04-30 11:47:13 +01:00
parent 79c6671500
commit a4857c08ab
3 changed files with 90 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ from flask import (
current_app
)
from app.aws.s3 import get_job_metadata_from_s3
from app.dao.jobs_dao import (
dao_create_job,
dao_update_job,
@@ -119,6 +120,13 @@ def create_job(service_id):
data.update({
"service": service_id
})
try:
data.update(
**get_job_metadata_from_s3(service_id, data['id'])
)
except KeyError:
raise InvalidRequest({'id': ['Missing data for required field.']}, status_code=400)
template = dao_get_template_by_id(data['template'])
if template.template_type == LETTER_TYPE and service.restricted: