Merge pull request #356 from sartography/bug/missing_pi_name_246
Bug/missing pi name 246
This commit is contained in:
commit
9ca3fd4e12
|
@ -14,7 +14,7 @@ local.properties
|
|||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
.vscode/
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
|
|
|
@ -979,7 +979,7 @@
|
|||
},
|
||||
"spiffworkflow": {
|
||||
"git": "https://github.com/sartography/SpiffWorkflow.git",
|
||||
"ref": "0b4a878f9b6d4f7fc320c26f59ca5e458a6130e8"
|
||||
"ref": "1df28b940ec0d32b672e59e3d17e7a804cb2b186"
|
||||
},
|
||||
"sqlalchemy": {
|
||||
"hashes": [
|
||||
|
|
|
@ -99,6 +99,12 @@ def user_studies():
|
|||
user = UserService.current_user(allow_admin_impersonate=True)
|
||||
StudyService.synch_with_protocol_builder_if_enabled(user)
|
||||
studies = StudyService().get_studies_for_user(user)
|
||||
if len(studies) == 0:
|
||||
studies = StudyService().get_studies_for_user(user, include_invalid=True)
|
||||
if len(studies) > 0:
|
||||
message = f"All studies associated with User: {user.display_name} failed study validation"
|
||||
raise ApiError(code="study_integrity_error", message=message)
|
||||
|
||||
results = StudySchema(many=True).dump(studies)
|
||||
return results
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class StudyService(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_studies_for_user(self, user):
|
||||
def get_studies_for_user(self, user, include_invalid=False):
|
||||
"""Returns a list of all studies for the given user."""
|
||||
associated = session.query(StudyAssociated).filter_by(uid=user.uid, access=True).all()
|
||||
associated_studies = [x.study_id for x in associated]
|
||||
|
@ -51,7 +51,7 @@ class StudyService(object):
|
|||
|
||||
studies = []
|
||||
for study_model in db_studies:
|
||||
if self._is_valid_study(study_model.id):
|
||||
if include_invalid or self._is_valid_study(study_model.id):
|
||||
studies.append(StudyService.get_study(study_model.id, study_model, do_status=False))
|
||||
return studies
|
||||
|
||||
|
@ -130,7 +130,7 @@ class StudyService(object):
|
|||
return people
|
||||
else:
|
||||
raise ApiError('uid_not_associated_with_study', "user id %s was not associated with study number %d" % (uid,
|
||||
study_id))
|
||||
study_id))
|
||||
|
||||
@staticmethod
|
||||
def get_study_associates(study_id):
|
||||
|
|
|
@ -781,6 +781,7 @@ class WorkflowService(object):
|
|||
if not hasattr(spiff_task.task_spec, 'lane') or spiff_task.task_spec.lane is None:
|
||||
associated = StudyService.get_study_associates(processor.workflow_model.study.id)
|
||||
return [user.uid for user in associated if user.access]
|
||||
|
||||
if spiff_task.task_spec.lane not in spiff_task.data:
|
||||
return [] # No users are assignable to the task at this moment
|
||||
lane_users = spiff_task.data[spiff_task.task_spec.lane]
|
||||
|
@ -790,7 +791,7 @@ class WorkflowService(object):
|
|||
lane_uids = []
|
||||
for user in lane_users:
|
||||
if isinstance(user, dict):
|
||||
if 'value' in user and user['value'] is not None:
|
||||
if user.get("value"):
|
||||
lane_uids.append(user['value'])
|
||||
else:
|
||||
raise ApiError.from_task(code="task_lane_user_error", message="Spiff Task %s lane user dict must have a key called 'value' with the user's uid in it." %
|
||||
|
|
|
@ -56,7 +56,6 @@ class TestStudyDetailsDocumentsScript(BaseTest):
|
|||
|
||||
@patch('crc.services.protocol_builder.requests.get')
|
||||
def test_no_validation_error_when_correct_file_exists(self, mock_get):
|
||||
|
||||
mock_get.return_value.ok = True
|
||||
mock_get.return_value.text = self.protocol_builder_response('required_docs.json')
|
||||
|
||||
|
@ -105,8 +104,8 @@ class TestStudyDetailsDocumentsScript(BaseTest):
|
|||
workflow_model = StudyService._create_workflow_model(study, workflow_spec_model)
|
||||
irb_code = "UVACompl_PRCAppr" # The first file referenced in pb required docs.
|
||||
file = FileService.add_workflow_file(workflow_id=workflow_model.id,
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
processor = WorkflowProcessor(workflow_model)
|
||||
task = processor.next_task()
|
||||
FileDataSet().do_task(task, study.id, workflow_model.id, key="ginger", value="doodle", file_id=file.id)
|
||||
|
@ -126,8 +125,8 @@ class TestStudyDetailsDocumentsScript(BaseTest):
|
|||
workflow_model = StudyService._create_workflow_model(study, workflow_spec_model)
|
||||
irb_code = "UVACompl_PRCAppr" # The first file referenced in pb required docs.
|
||||
file = FileService.add_workflow_file(workflow_id=workflow_model.id,
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
processor = WorkflowProcessor(workflow_model)
|
||||
task = processor.next_task()
|
||||
FileDataSet().do_task(task, study.id, workflow_model.id, key="irb_code", value="Study_App_Doc", file_id=file.id)
|
||||
|
@ -148,10 +147,10 @@ class TestStudyDetailsDocumentsScript(BaseTest):
|
|||
workflow_model = StudyService._create_workflow_model(study, workflow_spec_model)
|
||||
irb_code = "UVACompl_PRCAppr" # The first file referenced in pb required docs.
|
||||
file = FileService.add_workflow_file(workflow_id=workflow_model.id,
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
name="anything.png", content_type="text",
|
||||
binary_data=b'1234', irb_doc_code=irb_code)
|
||||
processor = WorkflowProcessor(workflow_model)
|
||||
task = processor.next_task()
|
||||
with self.assertRaises(ApiError):
|
||||
FileDataSet().do_task(task, study.id, workflow_model.id, key="irb_code", value="My_Pretty_Pony",
|
||||
file_id=file.id)
|
||||
file_id=file.id)
|
||||
|
|
|
@ -40,7 +40,7 @@ class TestTimerEvent(BaseTest):
|
|||
with self.assertLogs('crc', level='ERROR') as cm:
|
||||
WorkflowService.do_waiting()
|
||||
self.assertEqual(1, len(cm.output))
|
||||
self.assertRegexpMatches(cm.output[0], f"workflow #%i" % workflow.id)
|
||||
self.assertRegexpMatches(cm.output[0], f"study #%i" % workflow.study_id)
|
||||
self.assertRegex(cm.output[0], f"workflow #%i" % workflow.id)
|
||||
self.assertRegex(cm.output[0], f"study #%i" % workflow.study_id)
|
||||
|
||||
self.assertTrue(wf.status == WorkflowStatus.waiting)
|
||||
|
|
Loading…
Reference in New Issue