Check Study Associates Endpoint
This commit is contained in:
commit
f8dd4c3eb9
|
@ -14,7 +14,7 @@ local.properties
|
|||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
.vscode/
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
|
|
|
@ -190,8 +190,8 @@ paths:
|
|||
/workflow_sync/{workflow_spec_id}/spec:
|
||||
parameters:
|
||||
- name: workflow_spec_id
|
||||
required: true
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing workflow specification to modify.
|
||||
schema:
|
||||
type: string
|
||||
|
@ -394,6 +394,30 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Study"
|
||||
/study/{study_id}/associates:
|
||||
parameters:
|
||||
- name: study_id
|
||||
in: path
|
||||
required: true
|
||||
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 list of associates for a particular study
|
||||
tags:
|
||||
- Studies
|
||||
responses:
|
||||
'200':
|
||||
description: list of Study Associate Objects
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/StudyAssociate"
|
||||
|
||||
/workflow-specification:
|
||||
get:
|
||||
operationId: crc.api.workflow.all_specifications
|
||||
|
@ -561,7 +585,7 @@ paths:
|
|||
- name: test_until
|
||||
in: query
|
||||
required: false
|
||||
description: Optional name of task to stop validating at
|
||||
description: Optional name of task to stop validating at
|
||||
schema:
|
||||
type: string
|
||||
get:
|
||||
|
@ -1607,6 +1631,17 @@ components:
|
|||
type: string
|
||||
x-nullable: true
|
||||
example: "27b-6-1212"
|
||||
StudyAssociate:
|
||||
properties:
|
||||
uid:
|
||||
type: string
|
||||
example: "dhf8r"
|
||||
access:
|
||||
type: boolean
|
||||
example: False
|
||||
role:
|
||||
type: string
|
||||
example: "TODO"
|
||||
DocumentDirectory:
|
||||
properties:
|
||||
level:
|
||||
|
@ -1727,7 +1762,7 @@ components:
|
|||
example: "random_fact"
|
||||
x-nullable: true
|
||||
file:
|
||||
type: string
|
||||
type: string
|
||||
Workflow:
|
||||
properties:
|
||||
id:
|
||||
|
|
|
@ -71,9 +71,9 @@ def get_reference_file(name):
|
|||
file_data = FileService.get_reference_file_data(name)
|
||||
return send_file(
|
||||
io.BytesIO(file_data.data),
|
||||
attachment_filename=file_data.file_model.name,
|
||||
download_name=file_data.file_model.name,
|
||||
mimetype=file_data.file_model.content_type,
|
||||
cache_timeout=-1 # Don't cache these files on the browser.
|
||||
max_age=-1 # Don't cache these files on the browser.
|
||||
)
|
||||
|
||||
|
||||
|
@ -120,9 +120,9 @@ def get_file_data(file_id, version=None):
|
|||
raise ApiError('no_such_file', 'The file id you provided does not exist')
|
||||
return send_file(
|
||||
io.BytesIO(file_data.data),
|
||||
attachment_filename=file_data.file_model.name,
|
||||
download_name=file_data.file_model.name,
|
||||
mimetype=file_data.file_model.content_type,
|
||||
cache_timeout=-1, # Don't cache these files on the browser.
|
||||
max_age=-1, # Don't cache these files on the browser.
|
||||
last_modified=file_data.date_created
|
||||
)
|
||||
|
||||
|
@ -135,9 +135,9 @@ def get_file_data_link(file_id, auth_token, version=None):
|
|||
raise ApiError('no_such_file', 'The file id you provided does not exist')
|
||||
return send_file(
|
||||
io.BytesIO(file_data.data),
|
||||
attachment_filename=file_data.file_model.name,
|
||||
download_name=file_data.file_model.name,
|
||||
mimetype=file_data.file_model.content_type,
|
||||
cache_timeout=-1, # Don't cache these files on the browser.
|
||||
max_age=-1, # Don't cache these files on the browser.
|
||||
last_modified=file_data.date_created,
|
||||
as_attachment = True
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ from crc import session
|
|||
from crc.api.common import ApiError, ApiErrorSchema
|
||||
from crc.models.protocol_builder import ProtocolBuilderStatus
|
||||
from crc.models.study import Study, StudyEvent, StudyEventType, StudyModel, StudySchema, StudyForUpdateSchema, \
|
||||
StudyStatus
|
||||
StudyStatus, StudyAssociatedSchema
|
||||
from crc.services.study_service import StudyService
|
||||
from crc.services.user_service import UserService
|
||||
from crc.services.workflow_service import WorkflowService
|
||||
|
@ -81,6 +81,10 @@ def get_study(study_id, update_status=False):
|
|||
return StudySchema().dump(study)
|
||||
|
||||
|
||||
def get_study_associates(study_id):
|
||||
return StudyAssociatedSchema(many=True).dump(StudyService.get_study_associates(study_id))
|
||||
|
||||
|
||||
def delete_study(study_id):
|
||||
try:
|
||||
StudyService.delete_study(study_id)
|
||||
|
@ -95,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
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ def render_docx():
|
|||
return send_file(
|
||||
io.BytesIO(target_stream.read()),
|
||||
as_attachment=True,
|
||||
attachment_filename="output.docx",
|
||||
download_name="output.docx",
|
||||
mimetype="application/octet-stream",
|
||||
cache_timeout=-1 # Don't cache these files on the browser.
|
||||
max_age=-1 # Don't cache these files on the browser.
|
||||
)
|
||||
except ValueError as e:
|
||||
raise ApiError(code="undefined_field", message=str(e))
|
||||
|
|
|
@ -80,6 +80,13 @@ class StudyAssociated(db.Model):
|
|||
send_email = db.Column(db.Boolean, nullable=True)
|
||||
access = db.Column(db.Boolean, nullable=True)
|
||||
|
||||
|
||||
class StudyAssociatedSchema(ma.Schema):
|
||||
class Meta:
|
||||
fields=['uid', 'role', 'send_email', 'access']
|
||||
model = StudyAssociated
|
||||
unknown = INCLUDE
|
||||
|
||||
class StudyEvent(db.Model):
|
||||
__tablename__ = 'study_event'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
|
|
@ -114,7 +114,7 @@ email (subject="My Subject", recipients=["dhf8r@virginia.edu", pi.email], cc='as
|
|||
associated_emails = []
|
||||
associates = StudyService.get_study_associates(study_id)
|
||||
for associate in associates:
|
||||
if associate['send_email'] is True:
|
||||
user_info = LdapService.user_info(associate['uid'])
|
||||
if associate.send_email is True:
|
||||
user_info = LdapService.user_info(associate.uid)
|
||||
associated_emails.append(user_info.email_address)
|
||||
return associated_emails
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
from crc.api.common import ApiError
|
||||
from crc.models.study import StudyAssociatedSchema
|
||||
from crc.scripts.script import Script
|
||||
from crc.services.study_service import StudyService
|
||||
|
||||
|
||||
class GetStudyAssociates(Script):
|
||||
class GetStudyAssociate(Script):
|
||||
|
||||
|
||||
|
||||
def get_description(self):
|
||||
return """
|
||||
Returns people associated with a study or an error if one is not associated.
|
||||
Returns how a single person is associated with a study and what access they need,
|
||||
or raises an error if the person is not associated with the study.
|
||||
example : get_study_associate('sbp3ey') => {'uid':'sbp3ey','role':'Unicorn Herder', 'send_email': False,
|
||||
'access':True}
|
||||
|
||||
"""
|
||||
|
||||
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
||||
if len(args) < 1:
|
||||
raise ApiError('no_user_id_specified', 'A uva uid is the sole argument to this function')
|
||||
|
||||
return {'uid': 'sbp3ey', 'role': 'Unicorn Herder', 'send_email': False, 'access': True}
|
||||
|
||||
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
||||
|
@ -26,4 +26,5 @@ example : get_study_associate('sbp3ey') => {'uid':'sbp3ey','role':'Unicorn Herde
|
|||
raise ApiError('no_user_id_specified', 'A uva uid is the sole argument to this function')
|
||||
if not isinstance(args[0], str):
|
||||
raise ApiError('argument_should_be_string', 'A uva uid is always a string, please check type')
|
||||
return StudyService.get_study_associate(study_id=study_id, uid=args[0])
|
||||
associate = StudyService.get_study_associate(study_id=study_id, uid=args[0])
|
||||
return StudyAssociatedSchema().dump(associate)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from crc.api.common import ApiError
|
||||
from crc.models.study import StudyAssociatedSchema
|
||||
from crc.scripts.script import Script
|
||||
from crc.services.study_service import StudyService
|
||||
|
||||
|
@ -26,7 +27,6 @@ example : get_study_associates() => [{'uid':'sbp3ey','role':'Unicorn Herder', 's
|
|||
return study_associates
|
||||
|
||||
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
||||
|
||||
return StudyService.get_study_associates(study_id)
|
||||
return StudyAssociatedSchema(many=True).dump(StudyService.get_study_associates(study_id))
|
||||
|
||||
|
||||
|
|
|
@ -16,10 +16,11 @@ from crc.models.data_store import DataStoreModel
|
|||
from crc.models.email import EmailModel
|
||||
from crc.models.file import FileModel, File
|
||||
from crc.models.ldap import LdapSchema
|
||||
from crc.models.protocol_builder import ProtocolBuilderStudy
|
||||
from crc.models.study import StudyModel, Study, StudyStatus, Category, \
|
||||
WorkflowMetadata, StudyEventType, StudyEvent, IrbStatus, StudyAssociated
|
||||
from crc.models.task_event import TaskEventModel
|
||||
|
||||
from crc.models.protocol_builder import ProtocolBuilderStudy, ProtocolBuilderStatus
|
||||
from crc.models.study import StudyModel, Study, StudyStatus, Category, WorkflowMetadata, StudyEventType, StudyEvent, \
|
||||
IrbStatus, StudyAssociated, StudyAssociatedSchema
|
||||
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
|
||||
|
@ -41,17 +42,17 @@ 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 = session.query(StudyAssociated).filter_by(uid=user.uid, access=True).all()
|
||||
associated_studies = [x.study_id for x in associated]
|
||||
db_studies = session.query(StudyModel).filter((StudyModel.user_uid==user.uid)|
|
||||
db_studies = session.query(StudyModel).filter((StudyModel.user_uid == user.uid) |
|
||||
(StudyModel.id.in_(associated_studies))).all()
|
||||
|
||||
studies = []
|
||||
for study_model in db_studies:
|
||||
if self._is_valid_study(study_model.id):
|
||||
studies.append(StudyService.get_study(study_model.id, study_model,do_status=False))
|
||||
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
|
||||
|
||||
@staticmethod
|
||||
|
@ -75,8 +76,8 @@ class StudyService(object):
|
|||
|
||||
study = Study.from_model(study_model)
|
||||
study.create_user_display = LdapService.user_info(study.user_uid).display_name
|
||||
last_event: TaskEventModel = session.query(TaskEventModel)\
|
||||
.filter_by(study_id=study_id,action='COMPLETE')\
|
||||
last_event: TaskEventModel = session.query(TaskEventModel) \
|
||||
.filter_by(study_id=study_id, action='COMPLETE') \
|
||||
.order_by(TaskEventModel.date.desc()).first()
|
||||
if last_event is None:
|
||||
study.last_activity_user = 'Not Started'
|
||||
|
@ -108,9 +109,9 @@ class StudyService(object):
|
|||
return study
|
||||
|
||||
@staticmethod
|
||||
def get_study_associate(study_id = None, uid=None):
|
||||
def get_study_associate(study_id=None, uid=None):
|
||||
"""
|
||||
gets all associated people for a study from the database
|
||||
gets details on how one uid is related to a study, returns a StudyAssociated model
|
||||
"""
|
||||
study = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
|
||||
|
@ -118,23 +119,18 @@ class StudyService(object):
|
|||
raise ApiError('study_not_found', 'No study found with id = %d' % study_id)
|
||||
|
||||
if uid is None:
|
||||
raise ApiError('uid not specified','A valid uva uid is required for this function')
|
||||
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 StudyAssociated(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:
|
||||
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))
|
||||
people = db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id) &
|
||||
(StudyAssociated.uid == uid)).first()
|
||||
if people:
|
||||
return people
|
||||
else:
|
||||
raise ApiError('uid_not_associated_with_study', "user id %s was not associated with study number %d" % (uid,
|
||||
study_id))
|
||||
|
||||
@staticmethod
|
||||
def get_study_associates(study_id):
|
||||
|
@ -144,22 +140,15 @@ class StudyService(object):
|
|||
study = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
|
||||
if study is None:
|
||||
raise ApiError('study_not_found','No study found with id = %d'%study_id)
|
||||
|
||||
ownerid = study.user_uid
|
||||
people_list = [{'uid':ownerid,'role':'owner','send_email':True,'access':True}]
|
||||
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id)
|
||||
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
|
||||
raise ApiError('study_not_found', 'No study found with id = %d' % study_id)
|
||||
|
||||
people = db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id).all()
|
||||
owner = StudyAssociated(uid=study.user_uid, role='owner', send_email=True, access=True)
|
||||
people.append(owner)
|
||||
return people
|
||||
|
||||
@staticmethod
|
||||
def update_study_associates(study_id,associates):
|
||||
def update_study_associates(study_id, associates):
|
||||
"""
|
||||
updates the list of associates in the database for a study_id and a list
|
||||
of dicts that contains associates
|
||||
|
@ -168,20 +157,19 @@ class StudyService(object):
|
|||
raise ApiError('study_id not specified', "This function requires the study_id parameter")
|
||||
|
||||
for person in associates:
|
||||
if not LdapService.user_exists(person.get('uid','impossible_uid')):
|
||||
if person.get('uid','impossible_uid') == 'impossible_uid':
|
||||
raise ApiError('associate with no uid','One of the associates passed as a parameter doesnt have '
|
||||
if not LdapService.user_exists(person.get('uid', 'impossible_uid')):
|
||||
if person.get('uid', 'impossible_uid') == 'impossible_uid':
|
||||
raise ApiError('associate with no uid', 'One of the associates passed as a parameter doesnt have '
|
||||
'a uid specified')
|
||||
raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap',"You are trying to grant access to "
|
||||
"%s, but that user was not found in "
|
||||
"ldap "
|
||||
"- please check to ensure it is a "
|
||||
"valid uva uid"%person.get('uid'))
|
||||
raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap', "You are trying to grant access to "
|
||||
"%s, but that user was not found in "
|
||||
"ldap "
|
||||
"- please check to ensure it is a "
|
||||
"valid uva uid" % person.get('uid'))
|
||||
|
||||
study = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
if study is None:
|
||||
raise ApiError('study_id not found', "A study with id# %d was not found"%study_id)
|
||||
|
||||
raise ApiError('study_id not found', "A study with id# %d was not found" % study_id)
|
||||
|
||||
db.session.query(StudyAssociated).filter(StudyAssociated.study_id == study_id).delete()
|
||||
for person in associates:
|
||||
|
@ -190,27 +178,27 @@ class StudyService(object):
|
|||
newAssociate.uid = person['uid']
|
||||
newAssociate.role = person.get('role', None)
|
||||
newAssociate.send_email = person.get('send_email', False)
|
||||
newAssociate.access = person.get('access',False)
|
||||
newAssociate.access = person.get('access', False)
|
||||
session.add(newAssociate)
|
||||
session.commit()
|
||||
|
||||
@staticmethod
|
||||
def update_study_associate(study_id=None,uid=None,role="",send_email=False,access=False):
|
||||
def update_study_associate(study_id=None, uid=None, role="", send_email=False, access=False):
|
||||
if study_id is None:
|
||||
raise ApiError('study_id not specified', "This function requires the study_id parameter")
|
||||
if uid is None:
|
||||
raise ApiError('uid not specified', "This function requires a uva uid parameter")
|
||||
|
||||
if not LdapService.user_exists(uid):
|
||||
raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap',"You are trying to grant access to "
|
||||
"%s but they were not found in ldap "
|
||||
"- please check to ensure it is a "
|
||||
"valid uva uid"%uid)
|
||||
raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap', "You are trying to grant access to "
|
||||
"%s but they were not found in ldap "
|
||||
"- please check to ensure it is a "
|
||||
"valid uva uid" % uid)
|
||||
study = db.session.query(StudyModel).filter(StudyModel.id == study_id).first()
|
||||
if study is None:
|
||||
raise ApiError('study_id not found', "A study with id# %d was not found"%study_id)
|
||||
db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id)&(StudyAssociated.uid ==
|
||||
uid) ).delete()
|
||||
raise ApiError('study_id not found', "A study with id# %d was not found" % study_id)
|
||||
db.session.query(StudyAssociated).filter((StudyAssociated.study_id == study_id) & (StudyAssociated.uid ==
|
||||
uid)).delete()
|
||||
|
||||
newAssociate = StudyAssociated()
|
||||
newAssociate.study_id = study_id
|
||||
|
@ -222,7 +210,6 @@ class StudyService(object):
|
|||
session.commit()
|
||||
return True
|
||||
|
||||
|
||||
@staticmethod
|
||||
def delete_study(study_id):
|
||||
session.query(TaskEventModel).filter_by(study_id=study_id).delete()
|
||||
|
@ -305,18 +292,18 @@ class StudyService(object):
|
|||
# when we run tests - it doesn't look like the user is available
|
||||
# so we return a bogus token
|
||||
token = 'not_available'
|
||||
if hasattr(flask.g,'user'):
|
||||
if hasattr(flask.g, 'user'):
|
||||
token = flask.g.user.encode_auth_token()
|
||||
for file in doc_files:
|
||||
file_data = {'file_id': file.id,
|
||||
'name': file.name,
|
||||
'url': app.config['APPLICATION_ROOT']+
|
||||
'url': app.config['APPLICATION_ROOT'] +
|
||||
'file/' + str(file.id) +
|
||||
'/download?auth_token='+
|
||||
'/download?auth_token=' +
|
||||
urllib.parse.quote_plus(token),
|
||||
'workflow_id': file.workflow_id
|
||||
}
|
||||
data = db.session.query(DataStoreModel).filter(DataStoreModel.file_id==file.id).all()
|
||||
data = db.session.query(DataStoreModel).filter(DataStoreModel.file_id == file.id).all()
|
||||
data_store_data = {}
|
||||
for d in data:
|
||||
data_store_data[d.key] = d.value
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import copy
|
||||
import string
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
@ -312,7 +313,7 @@ class WorkflowService(object):
|
|||
data = {}
|
||||
if field.has_property(Task.FIELD_PROP_FILE_DATA) and \
|
||||
field.get_property(Task.FIELD_PROP_FILE_DATA) in data and \
|
||||
field.id in data:
|
||||
field.id in data and data[field.id]:
|
||||
file_id = data[field.get_property(Task.FIELD_PROP_FILE_DATA)]["id"]
|
||||
if field.type == 'enum':
|
||||
data_args = (field.id, data[field.id]['label'])
|
||||
|
@ -325,10 +326,19 @@ class WorkflowService(object):
|
|||
expression = field.get_property(property_name)
|
||||
data = task.data
|
||||
if field.has_property(Task.FIELD_PROP_REPEAT):
|
||||
# Then you must evaluate the expression based on the data within the group only.
|
||||
# Then you must evaluate the expression based on the data within the group, if that data exists.
|
||||
# There may not be data available in the group, if no groups where added
|
||||
group = field.get_property(Task.FIELD_PROP_REPEAT)
|
||||
if group in task.data:
|
||||
# Here we must make the current group data top level (as it would be in a repeat section) but
|
||||
# make all other top level task data available as well.
|
||||
new_data = copy.deepcopy(task.data)
|
||||
del(new_data[group])
|
||||
data = task.data[group][0]
|
||||
data.update(new_data)
|
||||
else:
|
||||
return None # We may not have enough information to process this
|
||||
|
||||
try:
|
||||
return task.workflow.script_engine.eval(expression, data)
|
||||
except Exception as e:
|
||||
|
@ -770,7 +780,8 @@ 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.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]
|
||||
|
@ -780,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." %
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_ef382ee" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
|
||||
<bpmn:process id="Process_eea3627" name="Test Empty Hidden Field" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_0eg42kv</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:userTask id="Activity_FileUpload" name="File Upload" camunda:formKey="UploadFile">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="UploadFile" label="Select File" type="file" />
|
||||
<camunda:formField id="Name" label="Enter Name" type="string">
|
||||
<camunda:properties>
|
||||
<camunda:property id="file_data" value="UploadFile" />
|
||||
</camunda:properties>
|
||||
</camunda:formField>
|
||||
<camunda:formField id="ExtraField" label="Could Be Hidden" type="string" defaultValue="Extra Field String">
|
||||
<camunda:properties>
|
||||
<camunda:property id="hide_expression" value="hide_field" />
|
||||
<camunda:property id="file_data" value="UploadFile" />
|
||||
</camunda:properties>
|
||||
</camunda:formField>
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_074gk91</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1gseke4</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:sequenceFlow id="Flow_0eg42kv" sourceRef="StartEvent_1" targetRef="Activity_AddData" />
|
||||
<bpmn:sequenceFlow id="Flow_074gk91" sourceRef="Activity_AddData" targetRef="Activity_FileUpload" />
|
||||
<bpmn:sequenceFlow id="Flow_1gseke4" sourceRef="Activity_FileUpload" targetRef="Activity_ViewData" />
|
||||
<bpmn:endEvent id="Event_0qcduja">
|
||||
<bpmn:incoming>Flow_04ozqju</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_04ozqju" sourceRef="Activity_ViewData" targetRef="Event_0qcduja" />
|
||||
<bpmn:manualTask id="Activity_ViewData" name="View Data">
|
||||
<bpmn:incoming>Flow_1gseke4</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_04ozqju</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
<bpmn:userTask id="Activity_AddData" name="Add Data" camunda:formKey="HideData">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="hide_field" label="Hide Field?" type="boolean">
|
||||
<camunda:validation>
|
||||
<camunda:constraint name="required" config="True" />
|
||||
</camunda:validation>
|
||||
</camunda:formField>
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_0eg42kv</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_074gk91</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_eea3627">
|
||||
<bpmndi:BPMNEdge id="Flow_04ozqju_di" bpmnElement="Flow_04ozqju">
|
||||
<di:waypoint x="690" y="117" />
|
||||
<di:waypoint x="752" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1gseke4_di" bpmnElement="Flow_1gseke4">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="590" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_074gk91_di" bpmnElement="Flow_074gk91">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0eg42kv_di" bpmnElement="Flow_0eg42kv">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0zui1g5_di" bpmnElement="Activity_FileUpload">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_0qcduja_di" bpmnElement="Event_0qcduja">
|
||||
<dc:Bounds x="752" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1fkiik9_di" bpmnElement="Activity_ViewData">
|
||||
<dc:Bounds x="590" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="UserTask_0wc78yf_di" bpmnElement="Activity_AddData">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.3">
|
||||
<bpmn:process id="Process_0exnnpv" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>SequenceFlow_1nfe5m9</bpmn:outgoing>
|
||||
|
@ -32,7 +32,7 @@ out4 = get_study_associate('lb3dp')</bpmn:script>
|
|||
<bpmn:outgoing>Flow_1vlh6s0</bpmn:outgoing>
|
||||
<bpmn:script>uids = []
|
||||
for assoc in out:
|
||||
uids.append(assoc['uid'])
|
||||
uids.append(assoc.uid)
|
||||
update_study_associates([{'uid':'lb3dp','role':'SuperGal','send_email':False,'access':True}])</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_1vlh6s0" sourceRef="Activity_0run091" targetRef="Activity_0d8iftx" />
|
||||
|
@ -46,6 +46,22 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
|
|||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0exnnpv">
|
||||
<bpmndi:BPMNEdge id="Flow_14n3ixy_di" bpmnElement="Flow_14n3ixy">
|
||||
<di:waypoint x="680" y="117" />
|
||||
<di:waypoint x="750" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1vlh6s0_di" bpmnElement="Flow_1vlh6s0">
|
||||
<di:waypoint x="850" y="117" />
|
||||
<di:waypoint x="900" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0cttkwp_di" bpmnElement="Flow_0cttkwp">
|
||||
<di:waypoint x="1000" y="117" />
|
||||
<di:waypoint x="1042" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_09cika8_di" bpmnElement="Flow_09cika8">
|
||||
<di:waypoint x="540" y="117" />
|
||||
<di:waypoint x="580" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1bqiin0_di" bpmnElement="SequenceFlow_1bqiin0">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="440" y="117" />
|
||||
|
@ -60,10 +76,6 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
|
|||
<bpmndi:BPMNShape id="ScriptTask_1mp6xid_di" bpmnElement="Task_Script_Load_Study_Sponsors">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_09cika8_di" bpmnElement="Flow_09cika8">
|
||||
<di:waypoint x="540" y="117" />
|
||||
<di:waypoint x="580" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="Activity_0wnwluq_di" bpmnElement="Activity_0cm6tn2">
|
||||
<dc:Bounds x="440" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
|
@ -73,24 +85,12 @@ out2 = get_study_associate('lb3dp')</bpmn:script>
|
|||
<bpmndi:BPMNShape id="Event_0c8gcuh_di" bpmnElement="Event_0c8gcuh">
|
||||
<dc:Bounds x="1042" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_0cttkwp_di" bpmnElement="Flow_0cttkwp">
|
||||
<di:waypoint x="1000" y="117" />
|
||||
<di:waypoint x="1042" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="Activity_0run091_di" bpmnElement="Activity_0run091">
|
||||
<dc:Bounds x="750" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_1vlh6s0_di" bpmnElement="Flow_1vlh6s0">
|
||||
<di:waypoint x="850" y="117" />
|
||||
<di:waypoint x="900" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="Activity_14td33q_di" bpmnElement="Activity_14td33q">
|
||||
<dc:Bounds x="580" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_14n3ixy_di" bpmnElement="Flow_14n3ixy">
|
||||
<di:waypoint x="680" y="117" />
|
||||
<di:waypoint x="750" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -72,7 +72,7 @@ class TestFileService(BaseTest):
|
|||
file_data = FileService.get_workflow_data_files(workflow_id=workflow.id)
|
||||
self.assertEqual(1, len(file_data))
|
||||
self.assertEqual(2, file_data[0].version)
|
||||
self.assertEquals(4, file_data[0].size) # File dat size is included.
|
||||
self.assertEqual(4, file_data[0].size) # File dat size is included.
|
||||
|
||||
def test_add_file_from_form_increments_version_and_replaces_on_subsequent_add_with_same_name(self):
|
||||
self.load_example_data()
|
||||
|
|
|
@ -191,7 +191,7 @@ class TestFilesApi(BaseTest):
|
|||
rv = self.app.post('/v1.0/file?workflow_spec_id=%s' % spec.id, data=data, follow_redirects=True,
|
||||
content_type='multipart/form-data', headers=self.logged_in_headers())
|
||||
file_json = json.loads(rv.get_data(as_text=True))
|
||||
self.assertEquals(80, file_json['size'])
|
||||
self.assertEqual(80, file_json['size'])
|
||||
|
||||
data['file'] = io.BytesIO(self.minimal_bpmn("efghijk")), 'my_new_file.bpmn'
|
||||
rv = self.app.put('/v1.0/file/%i/data' % file_json['id'], data=data, follow_redirects=True,
|
||||
|
|
|
@ -53,20 +53,19 @@ class TestSudySponsorsScript(BaseTest):
|
|||
self.assertIn('sponsors', data)
|
||||
self.assertIn('out', data)
|
||||
print(data['out'])
|
||||
self.assertEquals([{'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
|
||||
{'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True}]
|
||||
, data['out'])
|
||||
self.assertEquals({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True}
|
||||
, data['out2'])
|
||||
|
||||
self.assertEquals([{'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
|
||||
{'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True}]
|
||||
, data['out3'])
|
||||
self.assertEquals({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True}
|
||||
, data['out4'])
|
||||
|
||||
|
||||
self.assertEquals(3, len(data['sponsors']))
|
||||
self.assertDictEqual({'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
|
||||
data['out'][1])
|
||||
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True},
|
||||
data['out'][0])
|
||||
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperDude', 'send_email': False, 'access': True},
|
||||
data['out2'])
|
||||
self.assertDictEqual({'uid': 'dhf8r', 'role': 'owner', 'send_email': True, 'access': True},
|
||||
data['out3'][1])
|
||||
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True},
|
||||
data['out3'][0])
|
||||
self.assertDictEqual({'uid': 'lb3dp', 'role': 'SuperGal', 'send_email': False, 'access': True},
|
||||
data['out4'])
|
||||
self.assertEqual(3, len(data['sponsors']))
|
||||
|
||||
|
||||
@patch('crc.services.protocol_builder.requests.get')
|
||||
|
|
|
@ -50,6 +50,6 @@ class TestSudySponsorsScript(BaseTest):
|
|||
data = processor.next_task().data
|
||||
self.assertIn('sponsors', data)
|
||||
self.assertIn('out', data)
|
||||
self.assertEquals('empty', data['empty'])
|
||||
self.assertEquals('newval', data['out'])
|
||||
self.assertEquals(3, len(data['sponsors']))
|
||||
self.assertEqual('empty', data['empty'])
|
||||
self.assertEqual('newval', data['out'])
|
||||
self.assertEqual(3, len(data['sponsors']))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from SpiffWorkflow.bpmn.PythonScriptEngine import Box
|
||||
|
||||
from tests.base_test import BaseTest
|
||||
|
@ -56,7 +55,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,15 +103,15 @@ 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)
|
||||
docs = StudyInfo().do_task(task, study.id, workflow_model.id, "documents")
|
||||
self.assertTrue(isinstance(docs, Box))
|
||||
self.assertEquals(1, len(docs.UVACompl_PRCAppr.files))
|
||||
self.assertEquals("doodle", docs.UVACompl_PRCAppr.files[0].data_store.ginger)
|
||||
self.assertEqual(1, len(docs.UVACompl_PRCAppr.files))
|
||||
self.assertEqual("doodle", docs.UVACompl_PRCAppr.files[0].data_store.ginger)
|
||||
|
||||
@patch('crc.services.protocol_builder.requests.get')
|
||||
def test_file_data_set_changes_irb_code(self, mock_get):
|
||||
|
@ -126,16 +124,15 @@ 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)
|
||||
docs = StudyInfo().do_task(task, study.id, workflow_model.id, "documents")
|
||||
self.assertTrue(isinstance(docs, Box))
|
||||
self.assertEquals(1, len(docs.Study_App_Doc.files))
|
||||
self.assertEquals("Study_App_Doc", docs.Study_App_Doc.files[0].data_store.irb_code)
|
||||
|
||||
self.assertEqual(1, len(docs.Study_App_Doc.files))
|
||||
self.assertEqual("Study_App_Doc", docs.Study_App_Doc.files[0].data_store.irb_code)
|
||||
|
||||
@patch('crc.services.protocol_builder.requests.get')
|
||||
def test_file_data_set_invalid_irb_code_fails(self, mock_get):
|
||||
|
@ -148,10 +145,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)
|
||||
|
|
|
@ -45,4 +45,4 @@ class TestSudySponsorsScript(BaseTest):
|
|||
self.assertTrue(processor.bpmn_workflow.is_completed())
|
||||
data = processor.next_task().data
|
||||
self.assertIn('sponsors', data)
|
||||
self.assertEquals(3, len(data['sponsors']))
|
||||
self.assertEqual(3, len(data['sponsors']))
|
||||
|
|
|
@ -28,11 +28,11 @@ class TestDocumentDirectories(BaseTest):
|
|||
self.assert_success(rv)
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
print(json_data)
|
||||
self.assertEquals(2, len(json_data))
|
||||
self.assertEquals('UVA Compliance', json_data[0]['level'])
|
||||
self.assertEquals('PRC Approval', json_data[0]['children'][0]['level'])
|
||||
self.assertEquals('something.png', json_data[0]['children'][0]['children'][0]['file']['name'])
|
||||
self.assertEquals('Study', json_data[1]['level'])
|
||||
self.assertEquals('Application', json_data[1]['children'][0]['level'])
|
||||
self.assertEquals('Document', json_data[1]['children'][0]['children'][0]['level'])
|
||||
self.assertEquals('anything.png', json_data[1]['children'][0]['children'][0]['children'][0]['file']['name'])
|
||||
self.assertEqual(2, len(json_data))
|
||||
self.assertEqual('UVA Compliance', json_data[0]['level'])
|
||||
self.assertEqual('PRC Approval', json_data[0]['children'][0]['level'])
|
||||
self.assertEqual('something.png', json_data[0]['children'][0]['children'][0]['file']['name'])
|
||||
self.assertEqual('Study', json_data[1]['level'])
|
||||
self.assertEqual('Application', json_data[1]['children'][0]['level'])
|
||||
self.assertEqual('Document', json_data[1]['children'][0]['children'][0]['level'])
|
||||
self.assertEqual('anything.png', json_data[1]['children'][0]['children'][0]['children'][0]['file']['name'])
|
||||
|
|
|
@ -106,6 +106,6 @@ class TestMultiinstanceTasksApi(BaseTest):
|
|||
self.assertEqual(WorkflowStatus.complete, workflow.status)
|
||||
data = workflow.next_task.data
|
||||
for key in data["StudyInfo"]["investigators"]:
|
||||
self.assertEquals("dhf8r@virginia.edu", data["StudyInfo"]["investigators"][key]['email'])
|
||||
self.assertEqual("dhf8r@virginia.edu", data["StudyInfo"]["investigators"][key]['email'])
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -24,5 +24,5 @@ class TestEmptyEnumList(BaseTest):
|
|||
service = WorkflowService()
|
||||
checkbox_enum_field = task.task_spec.form.fields[0]
|
||||
radio_enum_field = task.task_spec.form.fields[1]
|
||||
self.assertEquals([], service.get_default_value(checkbox_enum_field, task))
|
||||
self.assertEquals({'label': None, 'value': None}, service.get_default_value(radio_enum_field, task))
|
||||
self.assertEqual([], service.get_default_value(checkbox_enum_field, task))
|
||||
self.assertEqual({'label': None, 'value': None}, service.get_default_value(radio_enum_field, task))
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
from tests.base_test import BaseTest
|
||||
from io import BytesIO
|
||||
import json
|
||||
|
||||
|
||||
class TestHiddenFileDataField(BaseTest):
|
||||
|
||||
def test_hidden_file_data_field(self):
|
||||
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('hidden_file_data_field')
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
||||
self.complete_form(workflow, task, {'hide_field': True})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
||||
data = {'file': (BytesIO(b"abcdef"), 'test_file.txt')}
|
||||
rv = self.app.post('/v1.0/file?study_id=%i&workflow_id=%s&task_id=%s&form_field_key=%s' %
|
||||
(workflow.study_id, workflow.id, task.id, 'Study_App_Doc'), data=data, follow_redirects=True,
|
||||
content_type='multipart/form-data', headers=self.logged_in_headers())
|
||||
self.assert_success(rv)
|
||||
file_id = json.loads(rv.get_data())['id']
|
||||
|
||||
self.complete_form(workflow, task, {'UploadFile': {'id': file_id},
|
||||
'Name': 'Some Name String'})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
new_task = workflow_api.next_task
|
||||
self.assertEqual('Activity_ViewData', new_task.name)
|
||||
self.assertEqual('Some Name String', new_task.data['Name'])
|
||||
self.assertNotIn('ExtraField', new_task.data)
|
||||
|
||||
def test_not_hidden_file_data_field(self):
|
||||
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('hidden_file_data_field')
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
||||
self.complete_form(workflow, task, {'hide_field': False})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
||||
data = {'file': (BytesIO(b"abcdef"), 'test_file.txt')}
|
||||
rv = self.app.post('/v1.0/file?study_id=%i&workflow_id=%s&task_id=%s&form_field_key=%s' %
|
||||
(workflow.study_id, workflow.id, task.id, 'Study_App_Doc'), data=data, follow_redirects=True,
|
||||
content_type='multipart/form-data', headers=self.logged_in_headers())
|
||||
self.assert_success(rv)
|
||||
file_id = json.loads(rv.get_data())['id']
|
||||
|
||||
self.complete_form(workflow, task, {'UploadFile': {'id': file_id},
|
||||
'Name': 'Some Name String',
|
||||
'ExtraField': 'Some Extra String'})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
new_task = workflow_api.next_task
|
||||
self.assertEqual('Activity_ViewData', new_task.name)
|
||||
self.assertEqual('Some Name String', new_task.data['Name'])
|
||||
self.assertIn('ExtraField', new_task.data)
|
||||
self.assertEqual('Some Extra String', new_task.data['ExtraField'])
|
|
@ -145,5 +145,5 @@ class TestWorkflowSpecValidation(BaseTest):
|
|||
final_data = WorkflowService.test_spec(spec_model.id, required_only=True)
|
||||
self.assertIsNotNone(final_data)
|
||||
self.assertIn('enum_with_default', final_data)
|
||||
self.assertEquals('maybe', final_data['enum_with_default']['value'])
|
||||
self.assertEqual('maybe', final_data['enum_with_default']['value'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue