Add include_archived parameter to get_document_directory api endpoint

This commit is contained in:
mike cullerton 2022-04-22 13:35:14 -04:00
parent 39e005dc24
commit bc4109a9d0
2 changed files with 7 additions and 2 deletions

View File

@ -83,6 +83,11 @@ paths:
required : false
schema :
type : integer
- name : include_archived
in : query
required : false
schema :
type : boolean
get:
operationId: crc.api.document.get_document_directory
summary: Returns a directory of all files for study in a nested structure

View File

@ -5,12 +5,12 @@ from crc.services.lookup_service import LookupService
from crc.services.user_file_service import UserFileService
def get_document_directory(study_id, workflow_id=None):
def get_document_directory(study_id, workflow_id=None, include_archived=False):
"""
return a nested list of files arranged according to the category hierarchy
defined in the doc dictionary
"""
file_models = UserFileService.get_files_for_study(study_id=study_id)
file_models = UserFileService.get_files_for_study(study_id=study_id, irb_doc_code=None, include_archived=include_archived)
doc_dict = DocumentService.get_dictionary()
files = (File.from_file_model(model, doc_dict) for model in file_models)
directory = DocumentService.get_directory(doc_dict, files, workflow_id)