give an endpoint to return all files associated with a study

This commit is contained in:
Kelly McDonald 2021-04-12 12:23:33 -04:00
parent 069de83bd5
commit 949f3be403
2 changed files with 12 additions and 3 deletions

View File

@ -565,6 +565,12 @@ paths:
description: The unique key of a workflow task form field. Make sure this matches a document in the irb_documents.xslx reference sheet.
schema:
type: string
- name: study_id
in: query
required: false
description: The study that the files are related to
schema:
type: integer
get:
operationId: crc.api.file.get_files
summary: Provides a list of files that match the given parameters (such as a spec id) IMPORTANT, only includes metadata, not the file content.

View File

@ -17,12 +17,15 @@ def to_file_api(file_model):
FileService.get_doc_dictionary())
def get_files(workflow_spec_id=None, workflow_id=None, form_field_key=None):
if all(v is None for v in [workflow_spec_id, workflow_id, form_field_key]):
def get_files(workflow_spec_id=None, workflow_id=None, form_field_key=None,study_id=None):
if all(v is None for v in [workflow_spec_id, workflow_id, form_field_key,study_id]):
raise ApiError('missing_parameter',
'Please specify either a workflow_spec_id or a '
'workflow_id with an optional form_field_key')
if study_id is not None:
file_models = FileService.get_files_for_study(study_id=study_id)
else:
file_models = FileService.get_files(workflow_spec_id=workflow_spec_id,
workflow_id=workflow_id,
irb_doc_code=form_field_key)