2021-02-24 17:05:06 +00:00
|
|
|
from crc.api.common import ApiError
|
2021-08-10 20:16:08 +00:00
|
|
|
from crc.models.study import StudyAssociatedSchema
|
2021-02-24 17:05:06 +00:00
|
|
|
from crc.scripts.script import Script
|
|
|
|
from crc.services.study_service import StudyService
|
|
|
|
|
|
|
|
|
|
|
|
class GetStudyAssociates(Script):
|
|
|
|
|
|
|
|
argument_error_message = "You must supply at least one argument to the " \
|
|
|
|
"update_study_associates task, an array of objects in the form " \
|
|
|
|
"{'uid':'someid', 'role': 'text', 'send_email: 'boolean', " \
|
|
|
|
"'access':'boolean'} "
|
|
|
|
|
|
|
|
|
|
|
|
def get_description(self):
|
2021-09-22 16:12:26 +00:00
|
|
|
return """Returns all people associated with the study - Will always return the study owner as assocated
|
2021-02-24 17:05:06 +00:00
|
|
|
example : get_study_associates() => [{'uid':'sbp3ey','role':'Unicorn Herder', 'send_email': False, 'access':True}]
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
2021-03-16 12:57:30 +00:00
|
|
|
study_associates = [
|
2021-11-22 22:17:19 +00:00
|
|
|
{'uid': 'dhf8r', 'role': 'Chief Bee Keeper', 'send_email': True, 'access': True,
|
|
|
|
'ldap_info': {
|
|
|
|
'uid': 'dhf8r',
|
|
|
|
'display_name': "Dan Funk",
|
|
|
|
'email_address': 'dhf8r@virginia.edu',
|
|
|
|
'telephone_number': '',
|
|
|
|
'title': '',
|
|
|
|
'department': '',
|
|
|
|
'affiliation': '',
|
|
|
|
'sponsor_type': '',
|
|
|
|
}},
|
|
|
|
{'uid': 'lb3dp', 'role': 'Chief Cat Herder', 'send_email': True, 'access': True,
|
|
|
|
'ldap_info': {
|
|
|
|
'uid': 'dhf8r',
|
|
|
|
'display_name': "Dan Funk",
|
|
|
|
'email_address': 'dhf8r@virginia.edu',
|
|
|
|
'telephone_number': '',
|
|
|
|
'title': '',
|
|
|
|
'department': '',
|
|
|
|
'affiliation': '',
|
|
|
|
'sponsor_type': ''
|
|
|
|
}},
|
2021-03-16 12:57:30 +00:00
|
|
|
]
|
|
|
|
return study_associates
|
2021-02-24 17:05:06 +00:00
|
|
|
|
|
|
|
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
2021-08-10 20:16:08 +00:00
|
|
|
return StudyAssociatedSchema(many=True).dump(StudyService.get_study_associates(study_id))
|
2021-02-24 17:05:06 +00:00
|
|
|
|
|
|
|
|