2022-02-24 14:25:42 -05:00
|
|
|
from SpiffWorkflow.util.metrics import timeit
|
|
|
|
|
2021-01-04 10:53:21 -05:00
|
|
|
from crc.scripts.script import Script
|
2022-02-02 12:59:56 -05:00
|
|
|
from crc.services.user_file_service import UserFileService
|
2021-01-04 10:53:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
class IsFileUploaded(Script):
|
|
|
|
|
|
|
|
def get_description(self):
|
|
|
|
return """Test whether a file is uploaded for a study.
|
|
|
|
Pass in the IRB Doc Code for the file."""
|
|
|
|
|
|
|
|
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
2022-04-19 08:01:18 -04:00
|
|
|
return self.do_task(task, study_id, workflow_id, *args, **kwargs)
|
2021-01-04 10:53:21 -05:00
|
|
|
|
|
|
|
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
|
|
|
|
2022-02-24 14:25:42 -05:00
|
|
|
doc_code = args[0]
|
|
|
|
files = UserFileService.get_files_for_study(study_id, irb_doc_code=doc_code)
|
2022-04-15 11:44:38 -04:00
|
|
|
for file in files:
|
|
|
|
if file.archived is False:
|
|
|
|
return True
|
|
|
|
return False
|