mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 17:01:35 -05:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user