Saves form field key

This commit is contained in:
Aaron Louie 2020-02-11 15:03:25 -05:00
parent 0a3a932c50
commit b0b1a6e5e8
2 changed files with 14 additions and 1 deletions

View File

@ -36,7 +36,7 @@ def add_file(workflow_spec_id=None, study_id=None, workflow_id=None, task_id=Non
if workflow_spec_id:
file_model = FileService.add_workflow_spec_file(workflow_spec_id, file.filename, file.content_type, file.stream.read())
else:
file_model = FileService.add_task_file(study_id, workflow_id, task_id, file.filename, file.content_type, file.stream.read())
file_model = FileService.add_form_field_file(study_id, workflow_id, task_id, form_field_key, file.filename, file.content_type, file.stream.read())
return FileModelSchema().dump(file_model)

View File

@ -22,6 +22,19 @@ class FileService(object):
)
return FileService.update_file(file_model, binary_data, content_type)
@staticmethod
def add_form_field_file(study_id, workflow_id, task_id, form_field_key, name, content_type, binary_data):
"""Create a new file and associate it with a user task form field within a workflow."""
file_model = FileModel(
version=0,
study_id=study_id,
workflow_id=workflow_id,
task_id=task_id,
name=name,
form_field_key=form_field_key
)
return FileService.update_file(file_model, binary_data, content_type)
@staticmethod
def add_task_file(study_id, workflow_id, task_id, name, content_type, binary_data):
"""Create a new file and associate it with an executing task within a workflow."""