Merges getStudyAssociates() endpoint
This commit is contained in:
parent
4632c6374f
commit
a263447806
|
@ -14,7 +14,7 @@ local.properties
|
||||||
.settings/
|
.settings/
|
||||||
.loadpath
|
.loadpath
|
||||||
.recommenders
|
.recommenders
|
||||||
|
.vscode/
|
||||||
# External tool builders
|
# External tool builders
|
||||||
.externalToolBuilders/
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ class StudyAssociated(db.Model):
|
||||||
role = db.Column(db.String, nullable=True)
|
role = db.Column(db.String, nullable=True)
|
||||||
send_email = db.Column(db.Boolean, nullable=True)
|
send_email = db.Column(db.Boolean, nullable=True)
|
||||||
access = db.Column(db.Boolean, nullable=True)
|
access = db.Column(db.Boolean, nullable=True)
|
||||||
|
|
||||||
class StudyAssociatedSchema(ma.Schema):
|
class StudyAssociatedSchema(ma.Schema):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StudyAssociated
|
model = StudyAssociated
|
||||||
|
|
|
@ -24,6 +24,7 @@ from crc.models.task_event import TaskEventModel, TaskEvent
|
||||||
from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowModel, WorkflowSpecModel, WorkflowState, \
|
from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowModel, WorkflowSpecModel, WorkflowState, \
|
||||||
WorkflowStatus, WorkflowSpecDependencyFile
|
WorkflowStatus, WorkflowSpecDependencyFile
|
||||||
from crc.services.document_service import DocumentService
|
from crc.services.document_service import DocumentService
|
||||||
|
|
||||||
from crc.services.file_service import FileService
|
from crc.services.file_service import FileService
|
||||||
from crc.services.ldap_service import LdapService
|
from crc.services.ldap_service import LdapService
|
||||||
from crc.services.lookup_service import LookupService
|
from crc.services.lookup_service import LookupService
|
||||||
|
@ -129,7 +130,11 @@ class StudyService(object):
|
||||||
person = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id)&(
|
person = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id)&(
|
||||||
StudyAssociated.uid == uid)).first()
|
StudyAssociated.uid == uid)).first()
|
||||||
if person:
|
if person:
|
||||||
return StudyAssociatedSchema().dump(person)
|
newAssociate = {'uid': person.uid}
|
||||||
|
newAssociate['role'] = person.role
|
||||||
|
newAssociate['send_email'] = person.send_email
|
||||||
|
newAssociate['access'] = person.access
|
||||||
|
return newAssociate
|
||||||
raise ApiError('uid_not_associated_with_study',"user id %s was not associated with study number %d"%(uid,
|
raise ApiError('uid_not_associated_with_study',"user id %s was not associated with study number %d"%(uid,
|
||||||
study_id))
|
study_id))
|
||||||
|
|
||||||
|
@ -148,7 +153,12 @@ class StudyService(object):
|
||||||
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id)
|
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id)
|
||||||
|
|
||||||
people_list = [{'uid':ownerid,'role':'owner','send_email':True,'access':True}]
|
people_list = [{'uid':ownerid,'role':'owner','send_email':True,'access':True}]
|
||||||
people_list += StudyAssociatedSchema().dump(people, many=True)
|
for person in people:
|
||||||
|
newAssociate = {'uid':person.uid}
|
||||||
|
newAssociate['role'] = person.role
|
||||||
|
newAssociate['send_email'] = person.send_email
|
||||||
|
newAssociate['access'] = person.access
|
||||||
|
people_list.append(newAssociate)
|
||||||
return people_list
|
return people_list
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -765,7 +765,7 @@ class WorkflowService(object):
|
||||||
else:
|
else:
|
||||||
if not hasattr(spiff_task.task_spec, 'lane') or spiff_task.task_spec.lane is None:
|
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)
|
associated = StudyService.get_study_associates(processor.workflow_model.study.id)
|
||||||
return [user['uid'] for user in associated if user['access']]
|
return [user['uid'] for user in associated if user.get("access")]
|
||||||
if spiff_task.task_spec.lane not in spiff_task.data:
|
if spiff_task.task_spec.lane not in spiff_task.data:
|
||||||
return [] # No users are assignable to the task at this moment
|
return [] # No users are assignable to the task at this moment
|
||||||
lane_users = spiff_task.data[spiff_task.task_spec.lane]
|
lane_users = spiff_task.data[spiff_task.task_spec.lane]
|
||||||
|
@ -775,7 +775,7 @@ class WorkflowService(object):
|
||||||
lane_uids = []
|
lane_uids = []
|
||||||
for user in lane_users:
|
for user in lane_users:
|
||||||
if isinstance(user, dict):
|
if isinstance(user, dict):
|
||||||
if 'value' in user and user['value'] is not None:
|
if user.get("value"):
|
||||||
lane_uids.append(user['value'])
|
lane_uids.append(user['value'])
|
||||||
else:
|
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." %
|
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." %
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue