Change so that we always use the current workflow

This commit is contained in:
mike cullerton 2022-02-23 15:18:03 -05:00
parent 679a875666
commit d378078d6f
3 changed files with 13 additions and 21 deletions

View File

@ -13,30 +13,28 @@ class ModifySpreadsheet(Script):
@staticmethod
def get_parameters(args, kwargs):
parameters = {}
if len(args) == 4 or ('upload_workflow_id' in kwargs and 'irb_doc_code' in kwargs and 'cell' in kwargs and 'text' in kwargs):
if 'upload_workflow_id' in kwargs and 'irb_doc_code' in kwargs and 'line' in kwargs and 'text' in kwargs:
parameters['upload_workflow_id'] = (kwargs['upload_workflow_id'])
if len(args) == 3 or ('irb_doc_code' in kwargs and 'cell' in kwargs and 'text' in kwargs):
if 'irb_doc_code' in kwargs and 'line' in kwargs and 'text' in kwargs:
parameters['irb_doc_code'] = (kwargs['irb_doc_code'])
parameters['cell'] = (kwargs['cell'])
parameters['text'] = (kwargs['text'])
else:
parameters['upload_workflow_id'] = (args[0])
parameters['irb_doc_code'] = (args[1])
parameters['cell'] = (args[2])
parameters['text'] = (args[3])
parameters['irb_doc_code'] = (args[0])
parameters['cell'] = (args[1])
parameters['text'] = (args[2])
return parameters
def get_description(self):
return """Script to modify an existing spreadsheet.
It inserts text into a spreadsheet in the cell indicated.
Requires 'upload_workflow_id', 'irb_doc_code', 'cell', and 'text' parameters.
Example: modify_spreadsheet(1234, 'Finance_BCA', 'C4', 'This is my inserted text')
Example: modify_spreadsheet(upload_workflow_id=1234, irb_doc_code='Finance_BCA', cell='C4', text='This is my inserted text')
Requires 'irb_doc_code', 'cell', and 'text' parameters.
Example: modify_spreadsheet('Finance_BCA', 'C4', 'This is my inserted text')
Example: modify_spreadsheet(irb_doc_code='Finance_BCA', cell='C4', text='This is my inserted text')
"""
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
parameters = self.get_parameters(args, kwargs)
if len(parameters) == 4:
if len(parameters) == 3:
return parameters
else:
raise ApiError(code='missing_parameters',
@ -44,10 +42,10 @@ class ModifySpreadsheet(Script):
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
parameters = self.get_parameters(args, kwargs)
if len(parameters) == 4:
if len(parameters) == 3:
spreadsheet = session.query(FileModel). \
filter(FileModel.workflow_id == parameters['upload_workflow_id']). \
filter(FileModel.workflow_id == workflow_id). \
filter(FileModel.irb_doc_code == parameters['irb_doc_code']).\
first()
spreadsheet_data = session.query(FileDataModel).\

View File

@ -28,7 +28,7 @@
<bpmn:scriptTask id="Activity_ModifySpreadsheet" name="Modify Spreadsheet">
<bpmn:incoming>Flow_0fpc32g</bpmn:incoming>
<bpmn:outgoing>Flow_10ulj3l</bpmn:outgoing>
<bpmn:script>result = modify_spreadsheet(upload_workflow_id, 'Finance_BCA', cell_indicator, input_text)</bpmn:script>
<bpmn:script>result = modify_spreadsheet('Finance_BCA', cell_indicator, input_text)</bpmn:script>
</bpmn:scriptTask>
<bpmn:manualTask id="Activity_DisplayResults" name="Display Modify Results">
<bpmn:documentation>## Modify Results
@ -41,11 +41,6 @@
{{ Finance_BCA }}</bpmn:documentation>
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="upload_workflow_id" label="&#39;Upload Workflow ID&#39;" type="long">
<camunda:validation>
<camunda:constraint name="required" config="True" />
</camunda:validation>
</camunda:formField>
<camunda:formField id="cell_indicator" label="Cell Indicator" type="string">
<camunda:validation>
<camunda:constraint name="required" config="True" />

View File

@ -49,8 +49,7 @@ class TestModifySpreadsheet(BaseTest):
self.assertEqual(None, sheet[cell_indicator].value)
task = workflow_api.next_task
self.complete_form(workflow, task, {'upload_workflow_id': workflow.id,
'cell_indicator': cell_indicator,
self.complete_form(workflow, task, {'cell_indicator': cell_indicator,
'input_text': input_text})
sheet = self.get_sheet(workflow.id, irb_doc_code)