Fixed Associate API Endpoint description
This commit is contained in:
parent
4632c6374f
commit
a73d1794eb
|
@ -14,7 +14,7 @@ local.properties
|
|||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
.vscode/
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
|
|
|
@ -399,22 +399,24 @@ paths:
|
|||
- name: study_id
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the study for which workflows should be returned.
|
||||
description: The id of the study for which associates should be returned.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
get:
|
||||
operationId: crc.api.study.get_study_associates
|
||||
summary: Provides a single study
|
||||
summary: Provides a list of associates for a particular study
|
||||
tags:
|
||||
- Studies
|
||||
responses:
|
||||
'200':
|
||||
description: An Study Associate Object
|
||||
description: list of Study Associate Objects
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/StudyAssociate"
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/StudyAssociate"
|
||||
|
||||
/workflow-specification:
|
||||
get:
|
||||
|
@ -1589,39 +1591,15 @@ components:
|
|||
example: "27b-6-1212"
|
||||
StudyAssociate:
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
example: 1234
|
||||
title:
|
||||
uid:
|
||||
type: string
|
||||
example: The impact of fried pickles on beer consumption in bipedal software developers.
|
||||
last_updated:
|
||||
example: "dhf8r"
|
||||
access:
|
||||
type: boolean
|
||||
example: False
|
||||
role:
|
||||
type: string
|
||||
format: date_time
|
||||
example: "2019-12-25T09:12:33.001Z"
|
||||
primary_investigator_id:
|
||||
type: string
|
||||
x-nullable: true
|
||||
example: dhf8r
|
||||
user_uid:
|
||||
type: string
|
||||
example: dhf8r
|
||||
status:
|
||||
type: string
|
||||
enum: ['in_progress', 'hold', 'open_for_enrollment', 'abandoned']
|
||||
example: done
|
||||
sponsor:
|
||||
type: string
|
||||
x-nullable: true
|
||||
example: "Sartography Pharmaceuticals"
|
||||
ind_number:
|
||||
type: string
|
||||
x-nullable: true
|
||||
example: "27b-6-42"
|
||||
hsr_number:
|
||||
type: string
|
||||
x-nullable: true
|
||||
example: "27b-6-1212"
|
||||
example: "TODO"
|
||||
DocumentDirectory:
|
||||
properties:
|
||||
level:
|
||||
|
|
|
@ -79,6 +79,7 @@ class StudyAssociated(db.Model):
|
|||
role = db.Column(db.String, nullable=True)
|
||||
send_email = db.Column(db.Boolean, nullable=True)
|
||||
access = db.Column(db.Boolean, nullable=True)
|
||||
|
||||
class StudyAssociatedSchema(ma.Schema):
|
||||
class Meta:
|
||||
model = StudyAssociated
|
||||
|
|
|
@ -24,6 +24,7 @@ from crc.models.task_event import TaskEventModel, TaskEvent
|
|||
from crc.models.workflow import WorkflowSpecCategoryModel, WorkflowModel, WorkflowSpecModel, WorkflowState, \
|
||||
WorkflowStatus, WorkflowSpecDependencyFile
|
||||
from crc.services.document_service import DocumentService
|
||||
|
||||
from crc.services.file_service import FileService
|
||||
from crc.services.ldap_service import LdapService
|
||||
from crc.services.lookup_service import LookupService
|
||||
|
@ -122,14 +123,18 @@ class StudyService(object):
|
|||
raise ApiError('uid not specified','A valid uva uid is required for this function')
|
||||
|
||||
if uid == study.user_uid:
|
||||
return {'uid': ownerid, 'role': 'owner', 'send_email': True, 'access': True}
|
||||
return {'uid': uid, 'role': 'owner', 'send_email': True, 'access': True}
|
||||
|
||||
|
||||
|
||||
person = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id)&(
|
||||
StudyAssociated.uid == uid)).first()
|
||||
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,
|
||||
study_id))
|
||||
|
||||
|
@ -148,7 +153,12 @@ class StudyService(object):
|
|||
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id)
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -227,6 +237,7 @@ class StudyService(object):
|
|||
for workflow in session.query(WorkflowModel).filter_by(study_id=study_id):
|
||||
StudyService.delete_workflow(workflow.id)
|
||||
study = session.query(StudyModel).filter_by(id=study_id).first()
|
||||
study = session.query(StudyModel).filter_by(id=study_id).first()
|
||||
session.delete(study)
|
||||
session.commit()
|
||||
|
||||
|
@ -382,7 +393,6 @@ class StudyService(object):
|
|||
in sync with the studies available in protocol builder. """
|
||||
|
||||
if ProtocolBuilderService.is_enabled():
|
||||
|
||||
app.logger.info("The Protocol Builder is enabled. app.config['PB_ENABLED'] = " +
|
||||
str(app.config['PB_ENABLED']))
|
||||
|
||||
|
@ -398,10 +408,11 @@ class StudyService(object):
|
|||
for pb_study in pb_studies:
|
||||
new_status = None
|
||||
db_study = next((s for s in db_studies if s.id == pb_study.STUDYID), None)
|
||||
if not db_study:
|
||||
if not db_study: # Create a Study
|
||||
db_study = StudyModel(id=pb_study.STUDYID)
|
||||
db_study.status = None # Force a new sa
|
||||
new_status = StudyStatus.in_progress
|
||||
|
||||
session.add(db_study)
|
||||
db_studies.append(db_study)
|
||||
|
||||
|
|
|
@ -765,7 +765,7 @@ class WorkflowService(object):
|
|||
else:
|
||||
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']]
|
||||
return [user['uid'] for user in associated if user.get("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]
|
||||
|
@ -775,7 +775,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." %
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue