workflows: rename append_item to add_action and use it everywhere (#64723)
This commit is contained in:
parent
4c62cdaa55
commit
4470d1e76c
|
@ -12,7 +12,7 @@ from wcs.carddef import CardDef
|
|||
from wcs.categories import CardDefCategory
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowVariablesFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -553,14 +553,11 @@ def test_carddef_usage(pub):
|
|||
)
|
||||
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = baz_status.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(
|
||||
fields.ItemField(id='1', type='item', label='item', data_source={'type': 'carddef:foo'})
|
||||
)
|
||||
baz_status.items.append(display_form)
|
||||
display_form.parent = baz_status
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -494,17 +494,15 @@ def test_data_sources_view(pub):
|
|||
fields.ItemField(id='1', type='item', label='item', data_source={'type': data_source.slug})
|
||||
)
|
||||
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form = baz_status.add_action('form', id='_x')
|
||||
display_form.id = '_x'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(
|
||||
fields.ItemField(id='1', type='item', label='item', data_source={'type': data_source.slug})
|
||||
)
|
||||
baz_status.items.append(display_form)
|
||||
display_form.parent = baz_status
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -12,21 +12,14 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.wf.geolocate import GeolocateWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.notification import SendNotificationWorkflowStatusItem
|
||||
from wcs.wf.profile import UpdateUserProfileStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.sms import SendSMSWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -103,62 +96,41 @@ def test_deprecations(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st0 = workflow.add_status('Status0', 'st0')
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st0.add_action('displaymsg')
|
||||
display.message = 'message with [ezt] info'
|
||||
display.parent = st0
|
||||
st0.items.append(display)
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st0.add_action('webservice_call', id='_wscall')
|
||||
wscall.varname = 'xxx'
|
||||
wscall.url = 'http://remote.example.net/xml'
|
||||
wscall.post_data = {'str': 'abcd', 'evalme': '=form_number'}
|
||||
wscall.parent = st0
|
||||
st0.items.append(wscall)
|
||||
|
||||
sendsms = SendSMSWorkflowStatusItem()
|
||||
sendsms.id = '_sendsms'
|
||||
sendsms = st0.add_action('sendsms', id='_sendsms')
|
||||
sendsms.to = 'xxx'
|
||||
sendsms.parent = st0
|
||||
st0.items.append(sendsms)
|
||||
|
||||
item = SetBackofficeFieldsWorkflowStatusItem()
|
||||
item.id = '_item'
|
||||
item = st0.add_action('set-backoffice-fields', id='_item')
|
||||
item.fields = [{'field_id': 'bo1', 'value': '=form_var_foo'}]
|
||||
item.parent = st0
|
||||
st0.items.append(item)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st0.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
]
|
||||
create_formdata.parent = st0
|
||||
st0.items.append(create_formdata)
|
||||
|
||||
item = UpdateUserProfileStatusItem()
|
||||
item.id = '_item'
|
||||
item = st0.add_action('update_user_profile', id='_item2')
|
||||
item.fields = [{'field_id': '__email', 'value': '=form_var_foo'}]
|
||||
item.parent = st0
|
||||
st0.items.append(item)
|
||||
|
||||
sendmail = SendmailWorkflowStatusItem()
|
||||
sendmail.id = '_sendmail'
|
||||
sendmail = st0.add_action('sendmail', id='_sendmail')
|
||||
sendmail.to = ['=plop']
|
||||
sendmail.parent = st0
|
||||
st0.items.append(sendmail)
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st0.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(
|
||||
fields.StringField(id='0', label='Test', type='string', prefill={'type': 'formula', 'value': '1 + 2'})
|
||||
)
|
||||
display_form.parent = st0
|
||||
st0.items.append(display_form)
|
||||
|
||||
export_to = ExportToModel()
|
||||
export_to = st0.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.label = 'create doc'
|
||||
upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
|
||||
|
@ -166,10 +138,7 @@ def test_deprecations(pub):
|
|||
upload.fp.write(b'HELLO WORLD')
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
export_to.parent = st0
|
||||
st0.items.append(export_to)
|
||||
|
||||
for klass in (
|
||||
ExportToModel,
|
||||
|
@ -249,11 +218,8 @@ def test_deprecations_choice_label(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st0 = workflow.add_status('Status0', 'st0')
|
||||
|
||||
accept = ChoiceWorkflowStatusItem()
|
||||
accept.id = '_choice'
|
||||
accept = st0.add_action('choice', id='_choice')
|
||||
accept.label = '[test] action'
|
||||
accept.parent = st0
|
||||
st0.items.append(accept)
|
||||
|
||||
job = DeprecationsScanAfterJob()
|
||||
job.execute()
|
||||
|
@ -264,10 +230,8 @@ def test_deprecations_skip_invalid_ezt(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st0 = workflow.add_status('Status0', 'st0')
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st0.add_action('displaymsg')
|
||||
display.message = 'message with invalid [if-any] ezt'
|
||||
display.parent = st0
|
||||
st0.items.append(display)
|
||||
|
||||
job = DeprecationsScanAfterJob()
|
||||
job.execute()
|
||||
|
|
|
@ -23,7 +23,6 @@ from wcs.formdef import FormDef
|
|||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.template import get_current_theme
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.workflows import Workflow
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
@ -217,12 +216,9 @@ def test_settings_export_import(pub):
|
|||
|
||||
workflow = Workflow(name='Workflow One')
|
||||
st1 = workflow.add_status(name='st1')
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [role.id]
|
||||
commentable.label = 'foobar'
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
|
|
@ -16,25 +16,8 @@ from wcs.mail_templates import MailTemplate
|
|||
from wcs.qommon.errors import ConnectionError
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.assign_carddata import AssignCarddataWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.edit_carddata import EditCarddataWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.jump_on_submit import JumpOnSubmitWorkflowStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.remove_tracking_code import RemoveTrackingCodeWorkflowStatusItem
|
||||
from wcs.wf.roles import AddRoleWorkflowStatusItem, RemoveRoleWorkflowStatusItem
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import (
|
||||
Workflow,
|
||||
WorkflowBackofficeFieldsFormDef,
|
||||
|
@ -147,12 +130,9 @@ def test_workflows_svg(pub):
|
|||
|
||||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status(name='baz')
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [role.id]
|
||||
commentable.label = 'foobar'
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -171,10 +151,8 @@ def test_workflow_user_roles_svg(pub):
|
|||
|
||||
wf = Workflow(name='blah')
|
||||
st1 = wf.add_status('New')
|
||||
add_role = AddRoleWorkflowStatusItem()
|
||||
remove_role = RemoveRoleWorkflowStatusItem()
|
||||
st1.items.append(add_role)
|
||||
st1.items.append(remove_role)
|
||||
add_role = st1.add_action('add_role')
|
||||
remove_role = st1.add_action('remove_role')
|
||||
wf.store()
|
||||
|
||||
resp = app.get('/backoffice/workflows/%s/svg' % wf.id)
|
||||
|
@ -479,11 +457,9 @@ def test_workflows_copy_status_item(pub):
|
|||
workflow.add_status('Status2')
|
||||
st3 = workflow.add_status('Status3')
|
||||
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['_submitter']
|
||||
item.subject = 'bla'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.store()
|
||||
|
||||
create_superuser(pub)
|
||||
|
@ -511,11 +487,8 @@ def test_workflows_copy_status_item(pub):
|
|||
assert 'items/1/' in resp.text
|
||||
assert 'items/2/' in resp.text
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['unknown']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
pub.cfg['sp'] = {'idp-manage-roles': True}
|
||||
|
@ -622,9 +595,7 @@ def test_workflows_usage(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
item = st1.add_action('sendmail')
|
||||
workflow.store()
|
||||
|
||||
create_superuser(pub)
|
||||
|
@ -759,11 +730,8 @@ def test_workflows_export_import_create_role(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status(name='baz')
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [role.id]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -841,11 +809,8 @@ def test_workflows_duplicate(pub):
|
|||
assert Workflow.get(3).name == 'other copy'
|
||||
assert Workflow.get(3).slug == 'other-copy'
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', '_commentable')
|
||||
commentable.by = ['unknown']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
pub.cfg['sp'] = {'idp-manage-roles': True}
|
||||
|
@ -937,11 +902,11 @@ def test_workflows_status_reorder_actions(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status(name='baz')
|
||||
choice1 = st1.append_item('choice')
|
||||
choice1 = st1.add_action('choice')
|
||||
choice1.by = ['logged-users']
|
||||
choice1.status = 'wf-%s' % st1.id
|
||||
choice1.label = 'choice1'
|
||||
choice2 = st1.append_item('choice')
|
||||
choice2 = st1.add_action('choice')
|
||||
choice2.by = ['logged-users']
|
||||
choice2.status = 'wf-%s' % st1.id
|
||||
choice2.label = 'choice2'
|
||||
|
@ -1220,19 +1185,13 @@ def test_workflows_edit_jump_previous(pub):
|
|||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status(name='baz')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.timeout = 86400
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
ac1 = workflow.add_global_action('Action', 'ac1')
|
||||
|
||||
jump_global = JumpWorkflowStatusItem()
|
||||
jump_global.id = '_jump'
|
||||
jump_global = ac1.add_action('jump', id='_jump')
|
||||
jump_global.timeout = 86400
|
||||
ac1.items.append(jump_global)
|
||||
jump_global.parent = ac1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1271,12 +1230,9 @@ def test_workflows_edit_jump_timeout(pub):
|
|||
workflow = Workflow(name='foo')
|
||||
st1 = workflow.add_status(name='baz')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.status = '1'
|
||||
jump.timeout = 86400
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1311,12 +1267,9 @@ def test_workflows_jump_target_links(pub):
|
|||
st1 = workflow.add_status(name='baz')
|
||||
st2 = workflow.add_status(name='bar')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.timeout = 86400
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1550,10 +1503,7 @@ def test_workflows_edit_choice_action_line_details(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '1'
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
jump = st1.add_action('choice', id='1')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1620,12 +1570,10 @@ def test_workflows_choice_action_line_details_markup(pub):
|
|||
wf = Workflow(name='foo')
|
||||
st1 = wf.add_status('New')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '1'
|
||||
jump = st1.add_action('choice', id='1')
|
||||
jump.status = '1'
|
||||
jump.parent = st1
|
||||
jump.label = '<b>test</b>'
|
||||
st1.items.append(jump)
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1684,9 +1632,7 @@ def test_workflows_action_subpath(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message.parent = baz_status
|
||||
baz_status.items.append(display_message)
|
||||
baz_status.add_action('displaymsg', id='1')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1700,9 +1646,7 @@ def test_workflows_display_action_ezt_validation(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message.parent = baz_status
|
||||
baz_status.items.append(display_message)
|
||||
baz_status.add_action('displaymsg')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1803,9 +1747,7 @@ def test_workflows_variables_edit(pub):
|
|||
|
||||
workflow = Workflow.get(1)
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message.parent = baz_status
|
||||
baz_status.items.append(display_message)
|
||||
baz_status.add_action('displaymsg')
|
||||
workflow.store()
|
||||
|
||||
resp = app.get('/backoffice/workflows/1/variables/fields/')
|
||||
|
@ -1825,7 +1767,7 @@ def test_workflows_variables_edit_with_all_action_types(pub):
|
|||
workflow = Workflow(name='foo')
|
||||
status = workflow.add_status(name='baz')
|
||||
for item_class in item_classes:
|
||||
status.append_item(item_class.key)
|
||||
status.add_action(item_class.key)
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1879,9 +1821,8 @@ def test_workflows_export_to_model_action_display(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
export_to = ExportToModel()
|
||||
export_to = baz_status.add_action('export_to_model')
|
||||
export_to.label = 'create doc'
|
||||
baz_status.items.append(export_to)
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1914,9 +1855,8 @@ def test_workflows_variables_with_export_to_model_action(pub):
|
|||
|
||||
workflow = Workflow.get(1)
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
export_to = ExportToModel()
|
||||
export_to = baz_status.add_action('export_to_model')
|
||||
export_to.label = 'create doc'
|
||||
baz_status.items.append(export_to)
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -1930,9 +1870,7 @@ def test_workflows_variables_replacement(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message.parent = baz_status
|
||||
baz_status.items.append(display_message)
|
||||
baz_status.add_action('displaymsg', id='1')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -2444,7 +2382,7 @@ def test_workflows_global_actions_timeout_trigger_anchor_options(pub):
|
|||
|
||||
workflow = Workflow(name='global')
|
||||
action = workflow.add_global_action('Global')
|
||||
action.append_item('modify_criticality')
|
||||
action.add_action('modify_criticality')
|
||||
trigger = action.append_trigger('timeout')
|
||||
workflow.store()
|
||||
|
||||
|
@ -2486,7 +2424,7 @@ def test_workflows_global_actions_external_workflow_action(pub):
|
|||
wf = Workflow(name='external')
|
||||
action = wf.add_global_action('Global action')
|
||||
trigger = action.append_trigger('webservice')
|
||||
action.append_item('remove')
|
||||
action.add_action('remove')
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -2552,7 +2490,7 @@ def test_workflows_external_workflow_action_config(pub):
|
|||
action = external_wf.add_global_action('Global action')
|
||||
trigger = action.append_trigger('webservice')
|
||||
trigger.identifier = 'test'
|
||||
action.append_item('remove')
|
||||
action.add_action('remove')
|
||||
external_wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -2563,9 +2501,7 @@ def test_workflows_external_workflow_action_config(pub):
|
|||
|
||||
wf = Workflow(name='foo')
|
||||
st = wf.add_status('New')
|
||||
external = ExternalWorkflowGlobalAction()
|
||||
external.parent = st
|
||||
st.items.append(external)
|
||||
st.add_action('external_workflow_global_action')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -2606,35 +2542,23 @@ def test_workflows_create_formdata(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_resubmit'
|
||||
jump = st1.add_action('choice', id='_resubmit')
|
||||
jump.label = 'Resubmit'
|
||||
jump.by = ['_submitter']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
redirect = RedirectToUrlWorkflowStatusItem()
|
||||
redirect.id = '_redirect'
|
||||
redirect = st2.add_action('redirect_to_url', id='_redirect')
|
||||
redirect.url = '{{ form_links_resubmitted.form_url }}'
|
||||
redirect.parent = st2
|
||||
st2.items.append(redirect)
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st2.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st1.id
|
||||
jump.parent = st2
|
||||
st2.items.append(jump)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -2707,9 +2631,7 @@ def test_workflows_create_formdata_action_config(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='create-formdata')
|
||||
st = wf.add_status('New')
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.parent = st
|
||||
st.items.append(create_formdata)
|
||||
st.add_action('create_formdata')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -2749,15 +2671,12 @@ def test_workflows_create_formdata_deleted_field(pub):
|
|||
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='{{ "a" }}'),
|
||||
Mapping(field_id='1', expression='{{ "b" }}'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -2792,9 +2711,7 @@ def test_workflows_create_carddata_action_config(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='create-carddata')
|
||||
st = wf.add_status('New')
|
||||
create_carddata = CreateCarddataWorkflowStatusItem()
|
||||
create_carddata.parent = st
|
||||
st.items.append(create_carddata)
|
||||
st.add_action('create_carddata')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -2826,10 +2743,8 @@ def test_workflows_create_formdata_expression_types(pub):
|
|||
|
||||
wf = Workflow(name='create-formdata')
|
||||
st1 = wf.add_status('New')
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata = st1.add_action('create_formdata')
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
create_formdata.parent = st1
|
||||
st1.items.append(create_formdata)
|
||||
wf.store()
|
||||
|
||||
if not pub.site_options.has_section('options'):
|
||||
|
@ -2869,9 +2784,7 @@ def test_workflows_edit_carddata_action_config(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='edit-carddata')
|
||||
st = wf.add_status('New')
|
||||
edit_carddata = EditCarddataWorkflowStatusItem()
|
||||
edit_carddata.parent = st
|
||||
st.items.append(edit_carddata)
|
||||
st.add_action('edit_carddata')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -2943,9 +2856,7 @@ def test_workflows_assign_carddata_action_options(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='assign card')
|
||||
st = wf.add_status('New')
|
||||
assign_carddata = AssignCarddataWorkflowStatusItem()
|
||||
assign_carddata.parent = st
|
||||
st.items.append(assign_carddata)
|
||||
st.add_action('assign_carddata')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3179,9 +3090,7 @@ def test_workflows_wscall_label(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.parent = baz_status
|
||||
baz_status.items.append(wscall)
|
||||
wscall = baz_status.add_action('webservice_call')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3202,9 +3111,7 @@ def test_workflows_wscall_options(pub, value):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.parent = baz_status
|
||||
baz_status.items.append(wscall)
|
||||
baz_status.add_action('webservice_call')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3238,14 +3145,12 @@ def test_workflows_wscall_status_error(pub):
|
|||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
foo_status = workflow.add_status(name='foo')
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.parent = baz_status
|
||||
wscall = baz_status.add_action('webservice_call')
|
||||
wscall.action_on_app_error = foo_status.id
|
||||
wscall.action_on_4xx = foo_status.id
|
||||
wscall.action_on_5xx = foo_status.id
|
||||
wscall.action_on_bad_data = foo_status.id
|
||||
wscall.action_on_network_errors = foo_status.id
|
||||
baz_status.items.append(wscall)
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3265,9 +3170,7 @@ def test_workflows_wscall_empty_param_values(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.parent = baz_status
|
||||
baz_status.items.append(wscall)
|
||||
baz_status.add_action('webservice_call')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3287,9 +3190,7 @@ def test_workflows_form_action_config(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='foo')
|
||||
st = wf.add_status('New')
|
||||
form = FormWorkflowStatusItem()
|
||||
form.parent = st
|
||||
st.items.append(form)
|
||||
form = st.add_action('form')
|
||||
wf.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -3333,65 +3234,47 @@ def test_workflows_inspect_view(pub):
|
|||
workflow.variables_formdef.fields.append(fields.StringField(label='Test', type='string'))
|
||||
|
||||
foo_status = workflow.add_status(name='foo')
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.parent = foo_status
|
||||
jump = foo_status.add_action('choice')
|
||||
jump.backoffice_info_text = '<p>Hello</p>'
|
||||
foo_status.items.append(jump)
|
||||
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
baz_status.backoffice_info_text = 'Info text'
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall = baz_status.add_action('webservice_call')
|
||||
wscall.post_data = {'foo1': 'bar1'}
|
||||
wscall.qs_data = {}
|
||||
wscall.parent = baz_status
|
||||
baz_status.items.append(wscall)
|
||||
|
||||
dispatch1 = DispatchWorkflowStatusItem()
|
||||
dispatch1 = baz_status.add_action('dispatch')
|
||||
dispatch1.dispatch_type = 'automatic'
|
||||
dispatch1.rules = [
|
||||
{'role_id': role.id, 'value': 'foo'},
|
||||
]
|
||||
baz_status.items.append(dispatch1)
|
||||
dispatch2 = DispatchWorkflowStatusItem()
|
||||
dispatch2 = baz_status.add_action('dispatch')
|
||||
dispatch2.dispatch_type = 'manual'
|
||||
dispatch2.role_key = '_receiver'
|
||||
dispatch2.role_id = role.id
|
||||
baz_status.items.append(dispatch2)
|
||||
|
||||
baz_status.backoffice_info_text = '<p>Hello</p>'
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = baz_status.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(fields.StringField(label='Test', type='string'))
|
||||
display_form.formdef.fields.append(fields.StringField(label='Test2', type='string'))
|
||||
display_form.backoffice_info_text = '<p>Foo</p>'
|
||||
baz_status.items.append(display_form)
|
||||
display_form.parent = baz_status
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = baz_status.add_action('jump', id='_jump')
|
||||
jump.timeout = 86400
|
||||
jump.status = foo_status.id
|
||||
jump.condition = {'type': 'django', 'value': '1 == 1'}
|
||||
baz_status.items.append(jump)
|
||||
jump.parent = baz_status
|
||||
|
||||
invalid_jump = JumpWorkflowStatusItem()
|
||||
invalid_jump.id = '_invalid_jump'
|
||||
invalid_jump = baz_status.add_action('jump', id='_invalid_jump')
|
||||
invalid_jump.status = 'xxx'
|
||||
invalid_jump.condition = {'type': 'python', 'value': '0 == 0'}
|
||||
baz_status.items.append(invalid_jump)
|
||||
invalid_jump.parent = baz_status
|
||||
|
||||
ac1 = workflow.add_global_action('Action', 'ac1')
|
||||
ac1.backoffice_info_text = '<p>Foo</p>'
|
||||
|
||||
add_to_journal = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal.id = '_add_to_journal'
|
||||
add_to_journal = ac1.add_action('register-comment', id='_add_to_journal')
|
||||
add_to_journal.comment = 'HELLO WORLD'
|
||||
ac1.items.append(add_to_journal)
|
||||
add_to_journal.parent = ac1
|
||||
|
||||
trigger = ac1.triggers[0]
|
||||
assert trigger.key == 'manual'
|
||||
|
@ -3671,9 +3554,7 @@ def test_remove_tracking_code_details(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='foo')
|
||||
baz_status = workflow.add_status(name='baz')
|
||||
remove_code = RemoveTrackingCodeWorkflowStatusItem()
|
||||
remove_code.parent = baz_status
|
||||
baz_status.items.append(remove_code)
|
||||
remove_code = baz_status.add_action('remove_tracking_code')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
|
|
@ -12,8 +12,7 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.fields import BlockField, StringField
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.mail_templates import MailTemplate
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowVariablesFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
@ -108,23 +107,16 @@ def test_export_import_dependencies(pub):
|
|||
workflow.variables_formdef.fields = [StringField(label='Test', id='1')]
|
||||
|
||||
status = workflow.add_status('New')
|
||||
form = FormWorkflowStatusItem()
|
||||
form.parent = status
|
||||
status.items.append(form)
|
||||
status.add_action('form')
|
||||
|
||||
data_source = NamedDataSource(name='foobar')
|
||||
data_source.store()
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = status.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(StringField(label='Test', data_source={'type': 'foobar'}))
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
send_mail = SendmailWorkflowStatusItem()
|
||||
status.items.append(send_mail)
|
||||
send_mail.parent = status
|
||||
send_mail = status.add_action('sendmail')
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ from wcs.qommon import ods
|
|||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.editable import EditableWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.workflows import AttachmentEvolutionPart, Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -393,11 +391,8 @@ def test_formdata_edit(pub, local_user):
|
|||
status=403,
|
||||
)
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = workflow.possible_status[1].add_action('editable', id='_wfedit')
|
||||
wfedit.by = [local_user.roles[0]]
|
||||
workflow.possible_status[1].items.append(wfedit)
|
||||
wfedit.parent = workflow.possible_status[1]
|
||||
workflow.store()
|
||||
|
||||
get_app(pub).post_json(
|
||||
|
@ -546,12 +541,10 @@ def test_formdata_with_evolution_part_attachment_to(pub, local_user):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
add_to_journal = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal.id = '_add_to_journal'
|
||||
add_to_journal = st1.add_action('register-comment', id='_add_to_journal')
|
||||
add_to_journal.comment = 'HELLO WORLD'
|
||||
add_to_journal.attachments = ['form_var_file_raw']
|
||||
add_to_journal.to = [role.id]
|
||||
st1.items.append(add_to_journal)
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
@ -406,15 +405,13 @@ def test_formdef_schema(pub, access):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st2'
|
||||
jump.timeout = 100
|
||||
st1.items.append(jump)
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st2.add_action('jump')
|
||||
jump.status = 'st3'
|
||||
st2.items.append(jump)
|
||||
st2 = workflow.add_status('Status3', 'st3')
|
||||
workflow.add_status('Status3', 'st3')
|
||||
workflow.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(workflow)
|
||||
workflow.backoffice_fields_formdef.fields = [
|
||||
fields.StringField(id='bo1', label='1st backoffice field', type='string', varname='backoffice_blah'),
|
||||
|
|
|
@ -8,7 +8,6 @@ from wcs.blocks import BlockDef
|
|||
from wcs.categories import Category
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
@ -45,12 +44,9 @@ def formdef(pub):
|
|||
workflow = Workflow(name='Workflow One')
|
||||
new_status = workflow.add_status(name='New status')
|
||||
workflow.add_status(name='End status')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = new_status.add_action('jump', id='_jump')
|
||||
jump.status = '2'
|
||||
jump.timeout = 86400
|
||||
new_status.items.append(jump)
|
||||
jump.parent = new_status
|
||||
workflow.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(workflow)
|
||||
workflow.backoffice_fields_formdef.fields = [
|
||||
fields.BoolField(
|
||||
|
|
|
@ -9,9 +9,7 @@ from wcs.api_access import ApiAccess
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.register_comment import JournalEvolutionPart, RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.register_comment import JournalEvolutionPart
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -80,11 +78,9 @@ def admin_user():
|
|||
def test_workflow_trigger(pub, local_user):
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -140,11 +136,9 @@ def test_workflow_trigger(pub, local_user):
|
|||
def test_workflow_trigger_with_data(pub, local_user):
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -206,17 +200,13 @@ def test_workflow_trigger_with_file_data(pub, local_user):
|
|||
fields.FileField(id='bo1', label='bo field 1', type='file'),
|
||||
]
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st2
|
||||
setbo = st2.add_action('set-backoffice-fields')
|
||||
setbo.fields = [{'field_id': 'bo1', 'value': '{{ form_workflow_data_document }}'}]
|
||||
st2.items.append(setbo)
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -254,12 +244,10 @@ def test_workflow_trigger_with_file_data(pub, local_user):
|
|||
def test_workflow_trigger_with_condition(pub, local_user):
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.condition = {'type': 'django', 'value': 'form_var_foo == "bar"'}
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -295,16 +283,12 @@ def test_workflow_trigger_jump_once(pub, local_user):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
workflow.add_status('Status3', 'st3')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st2.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st3'
|
||||
st2.items.append(jump)
|
||||
jump.parent = st2
|
||||
workflow.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -339,11 +323,9 @@ def test_workflow_trigger_api_access(pub, local_user):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -394,11 +376,9 @@ def test_workflow_trigger_http_auth_access(pub, local_user):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -452,11 +432,8 @@ def test_workflow_global_webservice_trigger(pub, local_user, admin_user):
|
|||
trigger = ac1.append_trigger('webservice')
|
||||
trigger.identifier = 'plop'
|
||||
|
||||
add_to_journal = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal.id = '_add_to_journal'
|
||||
add_to_journal = ac1.add_action('register-comment', id='_add_to_journal')
|
||||
add_to_journal.comment = 'HELLO WORLD'
|
||||
ac1.items.append(add_to_journal)
|
||||
add_to_journal.parent = ac1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -561,11 +538,8 @@ def test_workflow_global_webservice_trigger_no_trailing_slash(pub, local_user):
|
|||
trigger = ac1.append_trigger('webservice')
|
||||
trigger.identifier = 'plop'
|
||||
|
||||
add_to_journal = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal.id = '_add_to_journal'
|
||||
add_to_journal = ac1.add_action('register-comment', id='_add_to_journal')
|
||||
add_to_journal.comment = 'HELLO WORLD'
|
||||
ac1.items.append(add_to_journal)
|
||||
add_to_journal.parent = ac1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -21,21 +21,8 @@ from wcs.qommon.http_request import HTTPRequest
|
|||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.roles import logged_users_role
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.editable import EditableWorkflowStatusItem
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.jump_on_submit import JumpOnSubmitWorkflowStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.resubmit import ResubmitWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowCriticalityLevel
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -272,12 +259,9 @@ def test_backoffice_forms(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
st1 = workflow.add_status('Status1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.timeout = 86400
|
||||
jump.status = 'finished'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -392,12 +376,9 @@ def test_backoffice_listing(pub):
|
|||
workflow.id = '2'
|
||||
st1 = workflow.add_status('Status1')
|
||||
st1.id = 'plop'
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.timeout = 86400
|
||||
jump.status = 'finished'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -421,13 +402,10 @@ def test_backoffice_listing(pub):
|
|||
st1 = workflow.add_status('Status1')
|
||||
st1.id = 'plop'
|
||||
st1.forced_endpoint = False
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_receiver']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -610,7 +588,7 @@ def test_backoffice_multi_actions(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = ['whatever']
|
||||
|
@ -661,7 +639,7 @@ def test_backoffice_multi_actions(pub):
|
|||
|
||||
# action for other role
|
||||
action2 = workflow.add_global_action('OTHER ACTION')
|
||||
jump = action2.append_item('jump')
|
||||
jump = action2.add_action('jump')
|
||||
jump.status = 'accepted'
|
||||
trigger = action2.triggers[0]
|
||||
trigger.roles = ['whatever']
|
||||
|
@ -775,20 +753,17 @@ def test_backoffice_multi_actions_oldest_form(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('Mark as duplicates')
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.condition = {'type': 'django', 'value': "mass_action_index != 0"}
|
||||
jump.status = 'rejected'
|
||||
|
||||
jump2 = action.append_item('jump')
|
||||
jump2 = action.add_action('jump')
|
||||
jump2.condition = {'type': 'django', 'value': "mass_action_index == 0"}
|
||||
jump2.status = 'accepted'
|
||||
|
||||
register_comment = RegisterCommenterWorkflowStatusItem()
|
||||
register_comment.id = '_comment'
|
||||
register_comment = workflow.possible_status[2].add_action('register-comment', id='_comment')
|
||||
register_comment.comment = '<p>Original form: {{ oldest_form_number }}.</p>'
|
||||
assert workflow.possible_status[2].id == 'rejected'
|
||||
workflow.possible_status[2].items.append(register_comment)
|
||||
register_comment.parent = workflow.possible_status[2]
|
||||
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
@ -833,7 +808,7 @@ def test_backoffice_multi_actions_using_session_user(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('Show user')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'session_user={{session_user}}'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
@ -968,9 +943,9 @@ def test_backoffice_handling_global_action(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'HELLO WORLD GLOBAL ACTION'
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
@ -1005,7 +980,7 @@ def test_backoffice_global_remove_action(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
action.append_item('remove')
|
||||
action.add_action('remove')
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
||||
|
@ -1038,14 +1013,11 @@ def test_backoffice_global_action_jump_to_current_status(pub):
|
|||
|
||||
workflow = Workflow()
|
||||
st1 = workflow.add_status('Status1')
|
||||
register_comment = RegisterCommenterWorkflowStatusItem()
|
||||
register_comment.id = '_comment'
|
||||
register_comment = st1.add_action('register-comment', id='_comment')
|
||||
register_comment.comment = '<p>WORKFLOW COMMENT</p>'
|
||||
st1.items.append(register_comment)
|
||||
register_comment.parent = st1
|
||||
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
action.append_item('jump')
|
||||
action.add_action('jump')
|
||||
action.items[0].status = st1.id
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = [x.id for x in pub.role_class.select() if x.name == 'foobar']
|
||||
|
@ -1208,19 +1180,13 @@ def test_backoffice_info_text(pub):
|
|||
workflow = Workflow(name='info texts')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
commentable.button_label = 'CLICK ME!'
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
commentable2 = CommentableWorkflowStatusItem()
|
||||
commentable2.id = '_commentable2'
|
||||
commentable2 = st1.add_action('commentable', id='_commentable2')
|
||||
commentable2.by = ['_submitter']
|
||||
commentable2.button_label = 'CLICK ME2!'
|
||||
st1.items.append(commentable2)
|
||||
commentable2.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1351,22 +1317,16 @@ def test_backoffice_wscall_failure_display(http_requests, pub):
|
|||
workflow = Workflow(name='wscall')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st1.add_action('webservice_call', id='_wscall')
|
||||
wscall.varname = 'xxx'
|
||||
wscall.url = 'http://remote.example.net/xml'
|
||||
wscall.action_on_bad_data = ':stop'
|
||||
wscall.record_errors = True
|
||||
st1.items.append(wscall)
|
||||
wscall.parent = st1
|
||||
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_receiver']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1412,24 +1372,18 @@ def test_backoffice_wscall_on_error(http_requests, pub, emails, notify_on_errors
|
|||
workflow = Workflow(name='wscall')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st1.add_action('webservice_call', id='_wscall')
|
||||
wscall.varname = 'xxx'
|
||||
wscall.url = 'http://remote.example.net/xml'
|
||||
wscall.action_on_bad_data = ':stop'
|
||||
wscall.notify_on_errors = notify_on_errors
|
||||
wscall.record_on_errors = record_on_errors
|
||||
wscall.record_errors = True
|
||||
st1.items.append(wscall)
|
||||
wscall.parent = st1
|
||||
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_receiver']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1483,24 +1437,18 @@ def test_backoffice_wscall_attachment(http_requests, pub):
|
|||
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st1.add_action('webservice_call', id='_wscall')
|
||||
wscall.varname = 'xxx'
|
||||
wscall.response_type = 'attachment'
|
||||
wscall.backoffice_filefield_id = 'bo1'
|
||||
wscall.url = 'http://remote.example.net/xml'
|
||||
wscall.action_on_bad_data = ':stop'
|
||||
wscall.record_errors = True
|
||||
st1.items.append(wscall)
|
||||
wscall.parent = st1
|
||||
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_receiver']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1551,11 +1499,8 @@ def test_backoffice_wfedit(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1599,11 +1544,8 @@ def test_backoffice_wfedit_disabled(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1644,11 +1586,8 @@ def test_backoffice_wfedit_submission(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1685,19 +1624,13 @@ def test_backoffice_wfedit_and_required_comment(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [user.roles[0]]
|
||||
commentable.button_label = 'CLICK ME!'
|
||||
commentable.required = True
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1731,11 +1664,8 @@ def test_backoffice_wfedit_and_backoffice_fields(pub):
|
|||
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1775,11 +1705,8 @@ def test_backoffice_wfedit_and_data_source_with_user_info(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1829,11 +1756,8 @@ def test_backoffice_wfedit_and_workflow_data(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1884,11 +1808,8 @@ def test_backoffice_wfedit_and_data_source_with_field_info(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1935,11 +1856,8 @@ def test_backoffice_wfedit_and_user_selection(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -1976,11 +1894,8 @@ def test_backoffice_wfedit_and_user_selection_multi_page(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -2035,11 +1950,8 @@ def test_backoffice_wfedit_and_live_condition(pub):
|
|||
workflow = Workflow(name='wfedit')
|
||||
st1 = workflow.add_status('Status1', number31.status.split('-')[1])
|
||||
|
||||
wfedit = EditableWorkflowStatusItem()
|
||||
wfedit.id = '_wfedit'
|
||||
wfedit = st1.add_action('editable', id='_wfedit')
|
||||
wfedit.by = [user.roles[0]]
|
||||
st1.items.append(wfedit)
|
||||
wfedit.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -2963,23 +2875,14 @@ def test_backoffice_resubmit(pub):
|
|||
st1 = wf.add_status('Status1')
|
||||
st2 = wf.add_status('Status2')
|
||||
|
||||
resubmit = ResubmitWorkflowStatusItem()
|
||||
resubmit.id = '_resubmit'
|
||||
resubmit = st1.add_action('resubmit', id='_resubmit')
|
||||
resubmit.by = [user.roles[0]]
|
||||
st1.items.append(resubmit)
|
||||
resubmit.parent = st1
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
register_comment = RegisterCommenterWorkflowStatusItem()
|
||||
register_comment.id = '_register'
|
||||
register_comment = st2.add_action('register-comment', id='_register')
|
||||
register_comment.comment = '<p><a href="[resubmit_formdata_backoffice_url]">resubmitted</a></p>'
|
||||
st2.items.append(register_comment)
|
||||
register_comment.parent = st2
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3026,8 +2929,7 @@ def test_backoffice_workflow_display_form(pub):
|
|||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = [user.roles[0]]
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -3049,14 +2951,9 @@ def test_backoffice_workflow_display_form(pub):
|
|||
required=True,
|
||||
)
|
||||
)
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = status.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = 'accepted'
|
||||
status.items.append(jump)
|
||||
jump.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -3095,9 +2992,7 @@ def test_backoffice_workflow_form_with_conditions(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = [user.roles[0]]
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -3105,8 +3000,6 @@ def test_backoffice_workflow_form_with_conditions(pub):
|
|||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True),
|
||||
fields.StringField(id='2', label='Test2', varname='str2', type='string', required=True),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -3238,9 +3131,7 @@ def test_backoffice_workflow_form_with_live_data_source(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = [user.roles[0]]
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -3255,8 +3146,6 @@ def test_backoffice_workflow_form_with_live_data_source(pub):
|
|||
data_source={'type': 'json', 'value': 'https://www.example.invalid/{{ blah_var_str }}'},
|
||||
),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -3312,9 +3201,7 @@ def test_backoffice_workflow_display_form_with_block_add(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = [user.roles[0]]
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -3322,14 +3209,9 @@ def test_backoffice_workflow_display_form_with_block_add(pub):
|
|||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True),
|
||||
fields.BlockField(id='2', label='Blocks', type='block:foobar', varname='data', max_items=3),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = status.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = 'accepted'
|
||||
status.items.append(jump)
|
||||
jump.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -3414,13 +3296,10 @@ def test_workflow_jump_previous(pub):
|
|||
button_by_id = {}
|
||||
|
||||
def add_jump(label, src, dst_id):
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = str(random.random())
|
||||
jump = src.add_action('choice', id=str(random.random()))
|
||||
jump.label = label
|
||||
jump.by = ['logged-users']
|
||||
jump.status = dst_id
|
||||
src.items.append(jump)
|
||||
jump.parent = src
|
||||
if dst_id != '_previous':
|
||||
jump.set_marker_on_status = True
|
||||
button_by_id[label] = 'button%s' % jump.id
|
||||
|
@ -3435,11 +3314,8 @@ def test_workflow_jump_previous(pub):
|
|||
add_jump('Jump West', st3, st2.id)
|
||||
add_jump('Jump East', st2, st3.id)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_auto-jump'
|
||||
jump = st4.add_action('jump', id='_auto-jump')
|
||||
jump.status = st5.id
|
||||
st4.items.append(jump)
|
||||
jump.parent = st4
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3510,28 +3386,18 @@ def test_workflow_jump_previous_on_submit(pub):
|
|||
st2 = wf.add_status('South')
|
||||
st2.id = 'south'
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
commentable.button_label = 'CLICK ME!'
|
||||
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
jump.set_marker_on_status = True
|
||||
|
||||
back = ChoiceWorkflowStatusItem()
|
||||
back.id = '_back'
|
||||
back = st2.add_action('choice', id='_back')
|
||||
back.label = 'Back'
|
||||
back.by = ['_receiver']
|
||||
back.status = '_previous'
|
||||
st2.items.append(back)
|
||||
back.parent = st2
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3570,20 +3436,14 @@ def test_workflow_jump_previous_auto(pub):
|
|||
st2 = wf.add_status('South')
|
||||
st2.id = 'south'
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_auto-jump'
|
||||
jump = st1.add_action('jump', id='_auto-jump')
|
||||
jump.set_marker_on_status = True
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
back = ChoiceWorkflowStatusItem()
|
||||
back.id = '_back'
|
||||
back = st2.add_action('choice', id='_back')
|
||||
back.label = 'Back'
|
||||
back.by = ['_receiver']
|
||||
back.status = '_previous'
|
||||
st2.items.append(back)
|
||||
back.parent = st2
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3694,13 +3554,10 @@ def test_backoffice_logged_errors(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '12'
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
st1 = workflow.possible_status[0]
|
||||
jump = st1.add_action('jump', id='_jump', prepend=True)
|
||||
jump.status = 'rejected'
|
||||
jump.condition = {'type': 'python', 'value': '1//0'} # ZeroDivisionError
|
||||
st1 = workflow.possible_status[0]
|
||||
st1.items.insert(0, jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -3894,23 +3751,17 @@ def test_backoffice_display_message(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
display1 = DisplayMessageWorkflowStatusItem()
|
||||
display1 = st1.add_action('displaymsg')
|
||||
display1.message = 'message-to-all'
|
||||
display1.to = []
|
||||
st1.items.append(display1)
|
||||
display1.parent = st1
|
||||
|
||||
display2 = DisplayMessageWorkflowStatusItem()
|
||||
display2 = st1.add_action('displaymsg')
|
||||
display2.message = 'message-to-submitter'
|
||||
display2.to = ['_submitter']
|
||||
st1.items.append(display2)
|
||||
display2.parent = st1
|
||||
|
||||
display3 = DisplayMessageWorkflowStatusItem()
|
||||
display3 = st1.add_action('displaymsg')
|
||||
display3.message = 'message-to-receiver'
|
||||
display3.to = [user.roles[0]]
|
||||
st1.items.append(display3)
|
||||
display3.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -3942,13 +3793,10 @@ def test_backoffice_display_message(pub):
|
|||
resp = app.get(formdata.get_url(backoffice=True))
|
||||
assert 'message-to-all' not in resp.text # no actions no message
|
||||
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_receiver']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
workflow.store()
|
||||
|
||||
resp = app.get(formdata.get_url(backoffice=True))
|
||||
|
@ -4026,11 +3874,8 @@ def test_workflow_comment_required(pub):
|
|||
wf = Workflow(name='blah')
|
||||
st1 = wf.add_status('Comment')
|
||||
st1.id = 'comment'
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
|
@ -4088,8 +3933,7 @@ def test_lazy_eval_with_conditional_workflow_form(pub):
|
|||
st3 = wf.add_status('Done', 'done')
|
||||
|
||||
# first status with a workflow form, with a live conditional field.
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = st1.add_action('form', id='_display_form')
|
||||
display_form.by = [user.roles[0]]
|
||||
display_form.varname = 'local'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -4103,26 +3947,18 @@ def test_lazy_eval_with_conditional_workflow_form(pub):
|
|||
condition={'type': 'django', 'value': 'local_var_str'},
|
||||
),
|
||||
]
|
||||
display_form.parent = st1
|
||||
|
||||
submit_choice = JumpOnSubmitWorkflowStatusItem()
|
||||
submit_choice.parent = st1
|
||||
submit_choice = st1.add_action('jumponsubmit')
|
||||
submit_choice.status = st2.id
|
||||
st1.items.append(display_form)
|
||||
st1.items.append(submit_choice)
|
||||
|
||||
# jump to a second status, that set's a backoffice field data
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st2
|
||||
setbo = st2.add_action('set-backoffice-fields')
|
||||
setbo.fields = [{'field_id': 'bo1', 'value': 'go'}]
|
||||
|
||||
# and jump to the third status if the evoluation succeeds
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st2.add_action('jump')
|
||||
jump.condition = {'type': 'django', 'value': "form_var_foo_bar == 'go'"}
|
||||
jump.status = st3.id
|
||||
jump.parent = st2
|
||||
st2.items.append(setbo)
|
||||
st2.items.append(jump)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -4175,16 +4011,12 @@ def create_formdata(request, pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_resubmit'
|
||||
jump = st1.add_action('choice', id='_resubmit')
|
||||
jump.label = 'Resubmit'
|
||||
jump.by = ['_receiver']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.draft = True
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
|
@ -4195,20 +4027,12 @@ def create_formdata(request, pub):
|
|||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
redirect = RedirectToUrlWorkflowStatusItem()
|
||||
redirect.id = '_redirect'
|
||||
redirect = st2.add_action('redirect_to_url', id='_redirect')
|
||||
redirect.url = '{{ form_links_resubmitted.form_backoffice_url }}'
|
||||
redirect.parent = st2
|
||||
st2.items.append(redirect)
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st2.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st1.id
|
||||
jump.parent = st2
|
||||
st2.items.append(jump)
|
||||
|
||||
wf.store()
|
||||
source_formdef.workflow_id = wf.id
|
||||
|
@ -4429,31 +4253,23 @@ def test_backoffice_create_carddata_from_formdata(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Create card')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_createcard'
|
||||
jump = st1.add_action('choice', id='_createcard')
|
||||
jump.label = 'Create card'
|
||||
jump.by = ['_receiver']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_card = CreateCarddataWorkflowStatusItem()
|
||||
create_card = st2.add_action('create_carddata', id='_create')
|
||||
create_card.label = 'Create Card Data'
|
||||
create_card.varname = 'mycard'
|
||||
create_card.id = '_create'
|
||||
create_card.formdef_slug = carddef.url_name
|
||||
create_card.mappings = [
|
||||
Mapping(field_id='1', expression='Simple String'),
|
||||
Mapping(field_id='2', expression='{{ form_var_list_raw }}'),
|
||||
Mapping(field_id='3', expression='{{ form_var_date }}'),
|
||||
]
|
||||
create_card.parent = st2
|
||||
st2.items.append(create_card)
|
||||
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message = st2.add_action('displaymsg')
|
||||
display_message.message = 'Card nr. {{ form_links_mycard_form_number }} created'
|
||||
display_message.parent = st2
|
||||
st2.items.append(display_message)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -4492,12 +4308,9 @@ def test_backoffice_after_submit_location(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [logged_users_role().id]
|
||||
commentable.required = True
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -4520,11 +4333,9 @@ def test_backoffice_after_submit_location(pub):
|
|||
)
|
||||
resp = resp.follow()
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st1.add_action('displaymsg')
|
||||
display.message = 'message-to-all'
|
||||
display.to = []
|
||||
st1.items.append(display)
|
||||
display.parent = st1
|
||||
workflow.store()
|
||||
|
||||
resp.form['comment'] = 'plop'
|
||||
|
@ -4563,20 +4374,14 @@ def test_backoffice_dispatch_lose_access(pub):
|
|||
wf = Workflow(name='dispatch')
|
||||
|
||||
st1 = wf.add_status('Status1')
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_dispatch'
|
||||
dispatch = st1.add_action('dispatch', id='_dispatch')
|
||||
dispatch.role_key = '_receiver'
|
||||
dispatch.role_id = role2.id
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
|
||||
add_function = ChoiceWorkflowStatusItem()
|
||||
add_function.id = '_change_function'
|
||||
add_function = st1.add_action('choice', id='_change_function')
|
||||
add_function.label = 'Change function'
|
||||
add_function.by = ['_receiver']
|
||||
add_function.status = st1.id
|
||||
st1.items.append(add_function)
|
||||
add_function.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -4613,21 +4418,15 @@ def test_backoffice_dispatch_multi(pub):
|
|||
wf.roles['_foobar'] = 'Foobar'
|
||||
|
||||
st1 = wf.add_status('Status1')
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_dispatch'
|
||||
dispatch = st1.add_action('dispatch', id='_dispatch')
|
||||
dispatch.role_key = '_receiver'
|
||||
dispatch.role_id = role2.id
|
||||
dispatch.operation_mode = 'add'
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
|
||||
add_function = ChoiceWorkflowStatusItem()
|
||||
add_function.id = '_add_function'
|
||||
add_function = st1.add_action('choice', id='_add_function')
|
||||
add_function.label = 'Add function'
|
||||
add_function.by = ['_receiver']
|
||||
add_function.status = st1.id
|
||||
st1.items.append(add_function)
|
||||
add_function.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -4671,28 +4470,19 @@ def test_backoffice_dispatch_single_user(pub, user_template):
|
|||
wf.roles['_foobar'] = 'Foobar'
|
||||
|
||||
st1 = wf.add_status('Status1')
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_dispatch'
|
||||
dispatch = st1.add_action('dispatch', id='_dispatch')
|
||||
dispatch.role_key = '_foobar'
|
||||
dispatch.role_id = user_template
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
|
||||
add_function = ChoiceWorkflowStatusItem()
|
||||
add_function.id = '_add_function'
|
||||
add_function = st1.add_action('choice', id='_add_function')
|
||||
add_function.label = 'Add function'
|
||||
add_function.by = ['_receiver']
|
||||
add_function.status = st1.id
|
||||
st1.items.append(add_function)
|
||||
add_function.parent = st1
|
||||
|
||||
a_button = ChoiceWorkflowStatusItem()
|
||||
a_button.id = '_a_button'
|
||||
a_button = st1.add_action('choice', id='_a_button')
|
||||
a_button.label = 'A button'
|
||||
a_button.by = ['_foobar']
|
||||
a_button.status = st1.id
|
||||
st1.items.append(a_button)
|
||||
a_button.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@ from wcs.carddef import CardDef
|
|||
from wcs.categories import CardDefCategory
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -572,22 +570,16 @@ def test_backoffice_cards_wscall_failure_display(http_requests, pub):
|
|||
}
|
||||
st1 = workflow.add_status('Recorded', 'recorded')
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st1.add_action('webservice_call', id='_wscall')
|
||||
wscall.varname = 'xxx'
|
||||
wscall.url = 'http://remote.example.net/xml'
|
||||
wscall.action_on_bad_data = ':stop'
|
||||
wscall.record_errors = True
|
||||
st1.items.append(wscall)
|
||||
wscall.parent = st1
|
||||
|
||||
again = ChoiceWorkflowStatusItem()
|
||||
again.id = '_again'
|
||||
again = st1.add_action('choice', id='_again')
|
||||
again.label = 'Again'
|
||||
again.by = ['_editor']
|
||||
again.status = st1.id
|
||||
st1.items.append(again)
|
||||
again.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -11,9 +11,7 @@ from wcs.carddef import CardDef
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef, WorkflowCriticalityLevel
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -369,7 +367,7 @@ def test_inspect_page_with_related_objects(pub):
|
|||
external_wf = Workflow(name='External Workflow')
|
||||
st1 = external_wf.add_status(name='New')
|
||||
action = external_wf.add_global_action('Delete', 'delete')
|
||||
action.append_item('remove')
|
||||
action.add_action('remove')
|
||||
trigger = action.append_trigger('webservice')
|
||||
trigger.identifier = 'delete'
|
||||
external_wf.store()
|
||||
|
@ -396,34 +394,24 @@ def test_inspect_page_with_related_objects(pub):
|
|||
|
||||
# add a message to history, to check it doesn't interfer when searching for
|
||||
# linked data.
|
||||
register_comment = RegisterCommenterWorkflowStatusItem()
|
||||
register_comment.id = '_register'
|
||||
register_comment = st1.add_action('register-comment', id='_register')
|
||||
register_comment.comment = '<p>test</p>'
|
||||
st1.items.append(register_comment)
|
||||
register_comment.parent = st1
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata = st1.add_action('create_formdata', id='_create_form')
|
||||
create_formdata.label = 'create linked form'
|
||||
create_formdata.formdef_slug = external_formdef.url_name
|
||||
create_formdata.varname = 'created_form'
|
||||
create_formdata.id = '_create_form'
|
||||
mappings = [Mapping(field_id='0', expression='{{ form_var_string }}')]
|
||||
create_formdata.mappings = mappings
|
||||
create_formdata.parent = st1
|
||||
|
||||
create_carddata = CreateCarddataWorkflowStatusItem()
|
||||
create_carddata = st1.add_action('create_carddata', id='_create_card')
|
||||
create_carddata.label = 'create linked card'
|
||||
create_carddata.formdef_slug = external_carddef.url_name
|
||||
create_carddata.varname = 'created_card'
|
||||
create_carddata.id = '_create_card'
|
||||
create_carddata.mappings = mappings
|
||||
create_carddata.parent = st1
|
||||
|
||||
st1.items.append(create_formdata)
|
||||
st1.items.append(create_carddata)
|
||||
|
||||
global_action = wf.add_global_action('Delete external linked object', 'delete')
|
||||
action = global_action.append_item('external_workflow_global_action')
|
||||
action = global_action.add_action('external_workflow_global_action')
|
||||
action.slug = 'formdef:%s' % external_formdef.url_name
|
||||
action.trigger_id = 'action:%s' % trigger.identifier
|
||||
wf.store()
|
||||
|
@ -648,7 +636,7 @@ def test_inspect_page_actions_traces(pub):
|
|||
WorkflowCriticalityLevel(name='red'),
|
||||
]
|
||||
action = workflow.add_global_action('Timeout Test')
|
||||
action.append_item('modify_criticality')
|
||||
action.add_action('modify_criticality')
|
||||
trigger = action.append_trigger('timeout')
|
||||
trigger.anchor = 'creation'
|
||||
trigger.timeout = '2'
|
||||
|
|
|
@ -10,11 +10,6 @@ from wcs import fields
|
|||
from wcs.api_utils import sign_url
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -152,11 +147,8 @@ def test_backoffice_submission(pub):
|
|||
formdef = FormDef.get_by_urlname('form-title')
|
||||
wf = Workflow(name='dispatch')
|
||||
st1 = wf.add_status('Status1')
|
||||
item = RedirectToUrlWorkflowStatusItem()
|
||||
item.id = '_redirect'
|
||||
item = st1.add_action('redirect_to_url', id='_redirect')
|
||||
item.url = 'http://www.example.org/'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
wf.store()
|
||||
formdef.workflow_id = wf.id
|
||||
formdef.store()
|
||||
|
@ -510,12 +502,9 @@ def test_backoffice_submission_dispatch(pub):
|
|||
Workflow.wipe()
|
||||
wf = Workflow(name='dispatch')
|
||||
st1 = wf.add_status('Status1')
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_dispatch'
|
||||
dispatch = st1.add_action('dispatch', id='_dispatch')
|
||||
dispatch.role_key = '_receiver'
|
||||
dispatch.role_id = '2'
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -796,16 +785,12 @@ def test_backoffice_submission_conditional_jump_based_on_bo_field(pub):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st1
|
||||
setbo = st1.add_action('set-backoffice-fields')
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': 'go'}]
|
||||
st1.items.append(setbo)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.condition = {'type': 'django', 'value': "form_var_foo_bovar == 'go'"}
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1731,8 +1716,7 @@ def test_backoffice_submission_parent_var(pub):
|
|||
# workflow
|
||||
wf = Workflow(name='create-formdata')
|
||||
st1 = wf.add_status('New')
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st1.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.draft = True
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
|
@ -1740,8 +1724,6 @@ def test_backoffice_submission_parent_var(pub):
|
|||
create_formdata.backoffice_submission = True
|
||||
create_formdata.attach_to_history = True
|
||||
create_formdata.map_fields_by_varname = True
|
||||
create_formdata.parent = st1
|
||||
st1.items.append(create_formdata)
|
||||
wf.store()
|
||||
|
||||
source_formdef.workflow = wf
|
||||
|
|
|
@ -7,11 +7,7 @@ from wcs import fields
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.roles import AddRoleWorkflowStatusItem, RemoveRoleWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -44,12 +40,9 @@ def test_workflow_inspect_page(pub):
|
|||
|
||||
workflow = Workflow(name='blah')
|
||||
st1 = workflow.add_status('Status1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.timeout = '=86400'
|
||||
jump.status = 'finished'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -73,8 +66,7 @@ def test_workflow_inspect_page(pub):
|
|||
st2 = workflow.add_status('Status2')
|
||||
|
||||
target_formdef.store()
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.draft = True
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
|
@ -85,8 +77,6 @@ def test_workflow_inspect_page(pub):
|
|||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
Mapping(field_id='2', expression='=form_var_foobar_raw'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
workflow.store()
|
||||
|
||||
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
|
||||
|
@ -102,15 +92,13 @@ def test_workflow_inspect_page(pub):
|
|||
fields.StringField(id='bo2', label='Foo Bar 2', varname='foo_bar'),
|
||||
fields.StringField(id='bo3', label='Foo Bar 3', varname='foo_bar'),
|
||||
]
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st2
|
||||
setbo = st2.add_action('set-backoffice-fields')
|
||||
setbo.fields = [
|
||||
{'field_id': 'bo1', 'value': 'go'},
|
||||
{'field_id': 'bo2', 'value': ''},
|
||||
{'field_id': 'bo3', 'value': None},
|
||||
{'field_id': 'unknown', 'value': 'foobar'},
|
||||
]
|
||||
st2.items.append(setbo)
|
||||
workflow.store()
|
||||
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
|
||||
assert (
|
||||
|
@ -121,7 +109,7 @@ def test_workflow_inspect_page(pub):
|
|||
) in resp.text
|
||||
|
||||
st3 = workflow.add_status('Status3', 'st3')
|
||||
export_to = ExportToModel()
|
||||
export_to = st3.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.label = 'create doc'
|
||||
upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
|
||||
|
@ -129,10 +117,7 @@ def test_workflow_inspect_page(pub):
|
|||
upload.fp.write(b'HELLO WORLD')
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
st3.items.append(export_to)
|
||||
export_to.parent = st3
|
||||
workflow.store()
|
||||
|
||||
resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id)
|
||||
|
@ -148,10 +133,8 @@ def test_workflow_user_roles_inspect_page(pub):
|
|||
|
||||
wf = Workflow(name='blah')
|
||||
st1 = wf.add_status('New')
|
||||
add_role = AddRoleWorkflowStatusItem()
|
||||
remove_role = RemoveRoleWorkflowStatusItem()
|
||||
st1.items.append(add_role)
|
||||
st1.items.append(remove_role)
|
||||
add_role = st1.add_action('add_role')
|
||||
remove_role = st1.add_action('remove_role')
|
||||
wf.store()
|
||||
|
||||
resp = app.get('/backoffice/workflows/%s/inspect' % wf.id)
|
||||
|
|
|
@ -29,18 +29,8 @@ from wcs.qommon.substitution import CompatibilityNamesDict
|
|||
from wcs.qommon.template import Template
|
||||
from wcs.roles import logged_users_role
|
||||
from wcs.tracking_code import TrackingCode
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.editable import EditableWorkflowStatusItem
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.jump_on_submit import JumpOnSubmitWorkflowStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.resubmit import ResubmitWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.wf.wscall import JournalWsCallErrorPart
|
||||
from wcs.workflows import (
|
||||
AttachmentEvolutionPart,
|
||||
|
@ -2627,11 +2617,8 @@ def test_form_multi_page_post_edit(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st1.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(editable)
|
||||
editable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -2777,11 +2764,8 @@ def test_form_edit_autocomplete_list(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st1.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(editable)
|
||||
editable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -2837,11 +2821,9 @@ def test_form_count_dispatching(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.condition = {'type': 'python', 'value': 'form_objects.count_status_st2 < 1'}
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
@ -4973,18 +4955,14 @@ def test_form_workflow_trigger(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
jump2 = JumpWorkflowStatusItem()
|
||||
jump2 = st1.add_action('jump')
|
||||
jump2.trigger = 'YYY'
|
||||
jump2.status = 'st3'
|
||||
jump2.set_marker_on_status = True
|
||||
st1.items.append(jump2)
|
||||
jump2.parent = st1
|
||||
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.add_status('Status3', 'st3')
|
||||
|
@ -5049,11 +5027,9 @@ def test_form_worklow_multiple_identical_status(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
st1.extra_css_class = 'CSS-STATUS1'
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st1'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -5191,16 +5167,10 @@ def test_form_worklow_double_comments(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '1'
|
||||
commentable = st1.add_action('commentable', id='1')
|
||||
commentable.by = [logged_users_role().id]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '2'
|
||||
commentable = st1.add_action('commentable', id='2')
|
||||
commentable.by = [logged_users_role().id]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
wf.store()
|
||||
|
||||
formdef = create_formdef()
|
||||
|
@ -5230,36 +5200,26 @@ def test_display_message(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st0 = workflow.add_status('Status0', 'st0')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st0.add_action('jump')
|
||||
jump.status = 'st1'
|
||||
st0.items.append(jump)
|
||||
jump.parent = st0
|
||||
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
display1 = DisplayMessageWorkflowStatusItem()
|
||||
display1 = st1.add_action('displaymsg')
|
||||
display1.message = 'message-to-all'
|
||||
display1.to = []
|
||||
st1.items.append(display1)
|
||||
display1.parent = st1
|
||||
|
||||
display2 = DisplayMessageWorkflowStatusItem()
|
||||
display2 = st1.add_action('displaymsg')
|
||||
display2.message = 'message-to-submitter'
|
||||
display2.to = ['_submitter']
|
||||
st1.items.append(display2)
|
||||
display2.parent = st1
|
||||
|
||||
display3 = DisplayMessageWorkflowStatusItem()
|
||||
display3 = st1.add_action('displaymsg')
|
||||
display3.message = 'message-to-nobody'
|
||||
display3.to = ['xxx']
|
||||
st1.items.append(display3)
|
||||
display3.parent = st1
|
||||
|
||||
display4 = DisplayMessageWorkflowStatusItem()
|
||||
display4 = st1.add_action('displaymsg')
|
||||
display4.message = 'message-to-xxx-and-submitter'
|
||||
display4.to = ['_submitter', 'xxx']
|
||||
st1.items.append(display4)
|
||||
display4.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -5293,13 +5253,10 @@ def test_display_message(pub):
|
|||
assert 'message-to-xxx-and-submitter' in page.text
|
||||
|
||||
# add an action, so display2 will appear again
|
||||
jump1 = ChoiceWorkflowStatusItem()
|
||||
jump1.id = '_jump1'
|
||||
jump1 = st1.add_action('choice', id='_jump1')
|
||||
jump1.label = 'Jump 1'
|
||||
jump1.by = ['_submitter']
|
||||
jump1.status = st1.id
|
||||
jump1.parent = st1
|
||||
st1.items.append(jump1)
|
||||
workflow.store()
|
||||
|
||||
page = app.get(formdata.get_url())
|
||||
|
@ -5347,11 +5304,9 @@ def test_workflow_condition_on_message(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
display1 = DisplayMessageWorkflowStatusItem()
|
||||
display1 = st1.add_action('displaymsg')
|
||||
display1.message = 'message-to-all'
|
||||
display1.to = []
|
||||
st1.items.append(display1)
|
||||
display1.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -5387,11 +5342,9 @@ def test_workflow_message_with_template_error(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
display1 = DisplayMessageWorkflowStatusItem()
|
||||
display1 = st1.add_action('displaymsg')
|
||||
display1.message = '<p>{% for x in 0 %}crash{% endfor %}'
|
||||
display1.to = []
|
||||
st1.items.append(display1)
|
||||
display1.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -5509,11 +5462,9 @@ def test_form_worklow_multiple_identical_status_with_wserror(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'XXX'
|
||||
jump.status = 'st1'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -6650,13 +6601,11 @@ def test_logged_errors(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '12'
|
||||
jump = JumpWorkflowStatusItem()
|
||||
st1 = workflow.possible_status[0]
|
||||
jump = st1.add_action('jump', id='_jump', prepend=True)
|
||||
jump.id = '_jump'
|
||||
jump.status = 'rejected'
|
||||
jump.condition = {'type': 'python', 'value': '1//0'} # ZeroDivisionError
|
||||
st1 = workflow.possible_status[0]
|
||||
st1.items.insert(0, jump)
|
||||
jump.parent = st1
|
||||
workflow.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -6720,24 +6669,15 @@ def test_resubmit(pub):
|
|||
st1 = wf.add_status('Status1')
|
||||
st2 = wf.add_status('Status2')
|
||||
|
||||
resubmit = ResubmitWorkflowStatusItem()
|
||||
resubmit.id = '_resubmit'
|
||||
resubmit = st1.add_action('resubmit', id='_resubmit')
|
||||
resubmit.by = ['_submitter']
|
||||
resubmit.formdef_slug = formdef2.url_name
|
||||
st1.items.append(resubmit)
|
||||
resubmit.parent = st1
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
register_comment = RegisterCommenterWorkflowStatusItem()
|
||||
register_comment.id = '_register'
|
||||
register_comment = st2.add_action('register-comment', id='_register')
|
||||
register_comment.comment = '<p><a href="[resubmit_formdata_draft_url]">new draft</a></p>'
|
||||
st2.items.append(register_comment)
|
||||
register_comment.parent = st2
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -6856,9 +6796,9 @@ def test_user_global_action(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'HELLO WORLD GLOBAL ACTION'
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
|
||||
|
@ -6907,17 +6847,15 @@ def test_user_global_action_same_status_store(pub):
|
|||
fields.StringField(id='bo1', label='bo field 1', type='string'),
|
||||
]
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'new'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = ['_submitter']
|
||||
|
||||
new_status = workflow.possible_status[1]
|
||||
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = new_status
|
||||
setbo = new_status.add_action('set-backoffice-fields', prepend=True)
|
||||
setbo.fields = [{'field_id': 'bo1', 'value': '123'}]
|
||||
new_status.items = [setbo] + new_status.items
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -6957,9 +6895,9 @@ def test_anonymous_user_global_action(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'HELLO WORLD GLOBAL ACTION'
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = ['_submitter']
|
||||
|
@ -7064,22 +7002,20 @@ def test_user_global_action_along_form(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
action = workflow.add_global_action('FOOBAR')
|
||||
register_comment = action.append_item('register-comment')
|
||||
register_comment = action.add_action('register-comment')
|
||||
register_comment.comment = 'HELLO WORLD GLOBAL ACTION'
|
||||
jump = action.append_item('jump')
|
||||
jump = action.add_action('jump')
|
||||
jump.status = 'finished'
|
||||
trigger = action.triggers[0]
|
||||
trigger.roles = ['_submitter']
|
||||
|
||||
status = workflow.get_status('new')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form = status.add_action('form', id='_x')
|
||||
display_form.id = '_x'
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(fields.StringField(id='1', label='blah', type='string', required=True))
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -7513,11 +7449,9 @@ def test_field_unicode_condition_in_array(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
display1 = DisplayMessageWorkflowStatusItem()
|
||||
display1 = st1.add_action('displaymsg')
|
||||
display1.message = 'Message {% if "Pêche" in form_var_foo %}CHECK OK{% endif %}'
|
||||
display1.to = []
|
||||
st1.items.append(display1)
|
||||
display1.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow = workflow
|
||||
|
@ -7561,23 +7495,17 @@ def test_form_edit_and_backoffice_field_change(pub):
|
|||
fields.StringField(id='bo1', label='bo field 1', type='string', varname='plop'),
|
||||
]
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st1
|
||||
setbo = st1.add_action('set-backoffice-fields')
|
||||
setbo.fields = [{'field_id': 'bo1', 'value': '=form_var_foo'}]
|
||||
setbo2 = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo2.parent = st1
|
||||
setbo2 = st1.add_action('set-backoffice-fields')
|
||||
setbo2.fields = [{'field_id': 'bo1', 'value': '="foo" + form_var_plop'}]
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st2'
|
||||
st1.items = [setbo, setbo2, jump]
|
||||
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st2.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter']
|
||||
st2.items.append(editable)
|
||||
editable.parent = st2
|
||||
editable.status = st1.id
|
||||
workflow.store()
|
||||
|
||||
|
@ -7626,13 +7554,11 @@ def test_backoffice_fields_just_after_conditional_form_submit(pub):
|
|||
]
|
||||
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st1
|
||||
setbo = st1.add_action('set-backoffice-fields')
|
||||
setbo.fields = [
|
||||
{'field_id': 'bo1', 'value': '{{ form_var_listA }} vs {{ form_var_listB }}'},
|
||||
{'field_id': 'bo2', 'value': '{{ form_var_listA_more }} vs {{ form_var_listB_more }}'},
|
||||
]
|
||||
st1.items.append(setbo)
|
||||
workflow.store()
|
||||
|
||||
items_A = [{'id': '1', 'text': 'A1', 'more': 'moreA1'}]
|
||||
|
@ -7695,18 +7621,14 @@ def test_backoffice_fields_just_after_conditional_form_edit_action(pub):
|
|||
]
|
||||
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st1
|
||||
setbo = st1.add_action('set-backoffice-fields')
|
||||
setbo.fields = [
|
||||
{'field_id': 'bo1', 'value': '{{ form_var_listA }} vs {{ form_var_listB }}'},
|
||||
{'field_id': 'bo2', 'value': '{{ form_var_listA_more }} vs {{ form_var_listB_more }}'},
|
||||
]
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st1.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter']
|
||||
editable.parent = st1
|
||||
editable.status = st1.id
|
||||
st1.items = [setbo, editable]
|
||||
workflow.store()
|
||||
|
||||
items_A = [{'id': '1', 'text': 'A1', 'more': 'moreA1'}]
|
||||
|
@ -7804,13 +7726,11 @@ def test_backoffice_fields_set_from_live(pub):
|
|||
]
|
||||
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
setbo = SetBackofficeFieldsWorkflowStatusItem()
|
||||
setbo.parent = st1
|
||||
setbo = st1.add_action('set-backoffice-fields')
|
||||
setbo.fields = [
|
||||
{'field_id': 'bo1', 'value': '{{ form_var.foo.attr }}'},
|
||||
{'field_id': 'bo2', 'value': '{{ form_var.foo.live.var.attr }}'},
|
||||
]
|
||||
st1.items.append(setbo)
|
||||
workflow.store()
|
||||
|
||||
ds = {'type': 'carddef:%s' % carddef.url_name}
|
||||
|
@ -7881,9 +7801,7 @@ def test_frontoffice_workflow_form_with_conditions(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -7891,8 +7809,6 @@ def test_frontoffice_workflow_form_with_conditions(pub):
|
|||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True),
|
||||
fields.StringField(id='2', label='Test2', varname='str2', type='string', required=True),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = create_formdef()
|
||||
|
@ -8027,9 +7943,7 @@ def test_frontoffice_workflow_form_with_dynamic_comment(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -8037,8 +7951,6 @@ def test_frontoffice_workflow_form_with_dynamic_comment(pub):
|
|||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True),
|
||||
fields.CommentField(id='2', label='value is {{blah_var_str}}', type='comment'),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = create_formdef()
|
||||
|
@ -8073,9 +7985,7 @@ def test_frontoffice_workflow_form_with_impossible_condition(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -8094,8 +8004,6 @@ def test_frontoffice_workflow_form_with_impossible_condition(pub):
|
|||
condition={'type': 'django', 'value': 'blah_var_str == "toto"'},
|
||||
),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
formdef = create_formdef()
|
||||
|
@ -8134,8 +8042,7 @@ def test_frontoffice_workflow_form_with_attachment_and_python_datasource(pub):
|
|||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -8145,8 +8052,6 @@ def test_frontoffice_workflow_form_with_attachment_and_python_datasource(pub):
|
|||
id='2', label='Test List', type='item', varname='bar', data_source={'type': data_source.slug}
|
||||
),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -8185,29 +8090,20 @@ def test_choice_button_ignore_form_errors(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
st2 = wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [logged_users_role().id]
|
||||
commentable.required = True
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice = st1.add_action('choice', id='_x1')
|
||||
choice.label = 'Submit'
|
||||
choice.by = [logged_users_role().id]
|
||||
choice.id = '_x1'
|
||||
choice.status = st2.id
|
||||
st1.items.append(choice)
|
||||
choice.parent = st1
|
||||
|
||||
choice2 = ChoiceWorkflowStatusItem()
|
||||
choice2 = st1.add_action('choice', id='_x2')
|
||||
choice2.label = 'Submit no check'
|
||||
choice2.by = [logged_users_role().id]
|
||||
choice2.id = '_x2'
|
||||
choice2.status = st2.id
|
||||
choice2.ignore_form_errors = True
|
||||
st1.items.append(choice2)
|
||||
choice2.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -8314,41 +8210,30 @@ def create_formdata(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_resubmit'
|
||||
jump = st1.add_action('choice', id='_resubmit')
|
||||
jump.label = 'Resubmit'
|
||||
jump.by = ['_submitter']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.draft = True
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
Mapping(field_id='2', expression='=form_var_toto_item_raw'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
redirect = RedirectToUrlWorkflowStatusItem()
|
||||
redirect.id = '_redirect'
|
||||
redirect = st2.add_action('redirect_to_url', id='_redirect')
|
||||
redirect.url = '{{ form_links_resubmitted.form_url }}'
|
||||
redirect.parent = st2
|
||||
st2.items.append(redirect)
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display.id = '_display'
|
||||
display = st2.add_action('displaymsg', id='_display')
|
||||
display.message = '''<div class="linked">{% if form_links_resubmitted %}
|
||||
<p>Linked status: <span class="status">{{ form_links_resubmitted.form_status }}</span></p>
|
||||
<p>Target formdata field: <span class="foo_string">{{ form_links_resubmitted.form_var_foo_string }}</span></p>
|
||||
{% endif %}</div>'''
|
||||
display.to = []
|
||||
st2.items.append(display)
|
||||
|
||||
wf.store()
|
||||
source_formdef.workflow_id = wf.id
|
||||
|
@ -8555,12 +8440,9 @@ def test_after_submit_location(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [logged_users_role().id]
|
||||
commentable.required = True
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -8583,11 +8465,9 @@ def test_after_submit_location(pub):
|
|||
assert resp.location == 'http://example.net/test/1/#action-zone'
|
||||
resp = resp.follow()
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st1.add_action('displaymsg')
|
||||
display.message = 'message-to-all'
|
||||
display.to = []
|
||||
st1.items.append(display)
|
||||
display.parent = st1
|
||||
workflow.store()
|
||||
|
||||
resp.form['comment'] = 'plop'
|
||||
|
@ -8622,11 +8502,8 @@ def test_structured_workflow_options(pub):
|
|||
fields.DateField(id='4', label='Date', type='date', varname='date'),
|
||||
]
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '_comment'
|
||||
comment = st1.add_action('register-comment', id='_comment')
|
||||
comment.comment = 'Date option: {{ form_option_date }}'
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = create_formdef()
|
||||
|
@ -8707,11 +8584,8 @@ def test_exclude_self_condition(pub):
|
|||
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st1.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(editable)
|
||||
editable.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -8949,28 +8823,19 @@ def test_file_prefill_on_edit(pub, http_requests):
|
|||
st1 = workflow.add_status('New', 'st1')
|
||||
st2 = workflow.add_status('CreateFormdata')
|
||||
|
||||
editable = EditableWorkflowStatusItem()
|
||||
editable.id = '_editable'
|
||||
editable = st1.add_action('editable', id='_editable')
|
||||
editable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(editable)
|
||||
editable.parent = st1
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_resubmit'
|
||||
jump = st1.add_action('choice', id='_resubmit')
|
||||
jump.label = 'Resubmit'
|
||||
jump.by = ['_submitter']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.formdef_slug = formdef.url_name
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='{{form_var_foo_file}}'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
workflow.store()
|
||||
formdef.workflow_id = workflow.id
|
||||
|
@ -9042,17 +8907,13 @@ def test_workflow_form_structured_data(pub):
|
|||
|
||||
wf = Workflow(name='test')
|
||||
status = wf.add_status('New', 'st1')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [
|
||||
fields.BlockField(id='1', label='test', type='block:foobar', varname='fooblock'),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
wf.store()
|
||||
|
||||
formdef = create_formdef()
|
||||
|
@ -9128,20 +8989,14 @@ def test_rich_commentable_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [logged_users_role().id]
|
||||
commentable.required = True
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice = st1.add_action('choice', id='_x1')
|
||||
choice.label = 'Submit'
|
||||
choice.by = [logged_users_role().id]
|
||||
choice.id = '_x1'
|
||||
choice.status = st1.id
|
||||
st1.items.append(choice)
|
||||
choice.parent = st1
|
||||
wf.store()
|
||||
|
||||
formdef.workflow = wf
|
||||
|
@ -9214,17 +9069,13 @@ def test_jumps_with_by_and_no_trigger(pub):
|
|||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.by = [role.id]
|
||||
jump.parent = st1
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st3'
|
||||
st1.items.append(jump)
|
||||
jump.by = []
|
||||
jump.parent = st1
|
||||
|
||||
workflow.add_status('Status2', 'st2')
|
||||
workflow.add_status('Status3', 'st3')
|
||||
|
|
|
@ -10,8 +10,7 @@ from wcs.blocks import BlockDef
|
|||
from wcs.categories import Category
|
||||
from wcs.data_sources import NamedDataSource
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump_on_submit import JumpOnSubmitWorkflowStatusItem
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -688,14 +687,11 @@ def test_workflow_form_block_prefill(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(fields.BlockField(id='3', label='test', type='block:foobar'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1615,9 +1611,7 @@ def test_workflow_display_form_with_block_add(pub):
|
|||
wf.store()
|
||||
wf = Workflow.get(wf.id)
|
||||
status = wf.get_status('new')
|
||||
status.items = []
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -1625,14 +1619,9 @@ def test_workflow_display_form_with_block_add(pub):
|
|||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True),
|
||||
fields.BlockField(id='2', label='Blocks', type='block:foobar2', varname='data', max_items=3),
|
||||
]
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = status.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = 'accepted'
|
||||
status.items.append(jump)
|
||||
jump.parent = status
|
||||
|
||||
wf.store()
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ from wcs import fields
|
|||
from wcs.carddef import CardDef
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.substitution import CompatibilityNamesDict
|
||||
from wcs.wf.editable import EditableWorkflowStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -432,12 +431,10 @@ def test_computed_field_edit_action(pub):
|
|||
workflow = Workflow.get_default_workflow()
|
||||
workflow.id = '2'
|
||||
|
||||
editable = EditableWorkflowStatusItem()
|
||||
st2 = workflow.get_status('new')
|
||||
editable = st2.add_action('editable', id='_editable')
|
||||
editable.id = '_editable'
|
||||
editable.by = ['_submitter']
|
||||
st2 = workflow.get_status('new')
|
||||
st2.items.append(editable)
|
||||
editable.parent = st2
|
||||
workflow.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
|
|
@ -17,13 +17,8 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.misc import ConnectionError
|
||||
from wcs.wf.attachment import AddAttachmentWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import ExportToModel, transform_to_pdf
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import transform_to_pdf
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -75,11 +70,8 @@ def test_formdata_attachment_download(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -120,12 +112,9 @@ def test_formdata_attachment_download_with_substitution_variable(pub):
|
|||
create_user_and_admin(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.varname = 'attached_doc'
|
||||
attach.id = '_attach'
|
||||
attach.by = ['_submitter']
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -181,11 +170,8 @@ def test_formdata_attachment_download_with_invalid_character(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -218,12 +204,9 @@ def test_formdata_attachment_download_to_backoffice_file_field(pub):
|
|||
fields.FileField(id='bo1', label='bo field 1', type='file'),
|
||||
]
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
attach.backoffice_filefield_id = 'bo1'
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
assert attach.get_backoffice_filefield_options() == [('bo1', 'bo field 1', 'bo1')]
|
||||
|
@ -271,13 +254,10 @@ def test_formdata_attachment_download_to_backoffice_file_field_only(pub):
|
|||
fields.FileField(id='bo1', label='bo field 1', type='file'),
|
||||
]
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
attach.backoffice_filefield_id = 'bo1'
|
||||
attach.attach_to_history = False # store only in backoffice field
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
assert attach.get_backoffice_filefield_options() == [('bo1', 'bo field 1', 'bo1')]
|
||||
|
@ -319,14 +299,10 @@ def test_formdata_attachment_file_options(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
attach.document_type = {'label': 'Fichiers vidéo', 'mimetypes': ['video/*'], 'id': '_video'}
|
||||
attach.max_file_size = '3Mo'
|
||||
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -354,11 +330,8 @@ def test_formdata_attachment_pick_from_portfolio(pub, fargo_url):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
attach = AddAttachmentWorkflowStatusItem()
|
||||
attach.id = '_attach'
|
||||
attach = st1.add_action('addattachment', id='_attach')
|
||||
attach.by = ['_submitter']
|
||||
st1.items.append(attach)
|
||||
attach.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -390,7 +363,7 @@ def test_formdata_generated_document_download(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.label = 'create doc'
|
||||
upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
|
||||
|
@ -398,10 +371,7 @@ def test_formdata_generated_document_download(pub):
|
|||
upload.fp.write(b'HELLO WORLD')
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -483,7 +453,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.label = 'create doc'
|
||||
template_filename = os.path.join(os.path.dirname(__file__), '..', odt_template)
|
||||
|
@ -494,10 +464,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -575,7 +542,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
|
|||
create_user_and_admin(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.label = 'create doc'
|
||||
export_to.varname = 'created_doc'
|
||||
|
@ -587,10 +554,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -698,7 +662,7 @@ def test_formdata_generated_document_odt_to_pdf_download(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.label = 'create doc'
|
||||
export_to.varname = 'created_doc'
|
||||
template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
|
||||
|
@ -709,11 +673,8 @@ def test_formdata_generated_document_odt_to_pdf_download(pub):
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
export_to.convert_to_pdf = True
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -770,7 +731,7 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(
|
|||
pub.write_cfg()
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.label = 'create doc'
|
||||
export_to.varname = 'created_doc'
|
||||
template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
|
||||
|
@ -781,12 +742,9 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
export_to.convert_to_pdf = True
|
||||
export_to.push_to_portfolio = True
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
wf.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -861,7 +819,7 @@ def test_formdata_generated_document_non_interactive(pub):
|
|||
create_user(pub)
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.method = 'non-interactive'
|
||||
template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
|
||||
|
@ -872,15 +830,10 @@ def test_formdata_generated_document_non_interactive(pub):
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.attach_to_history = True
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
|
@ -924,7 +877,7 @@ def test_formdata_generated_document_to_backoffice_field(pub):
|
|||
]
|
||||
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.convert_to_pdf = False
|
||||
export_to.method = 'non-interactive'
|
||||
template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
|
||||
|
@ -935,18 +888,13 @@ def test_formdata_generated_document_to_backoffice_field(pub):
|
|||
upload.fp.write(template)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.id = '_export_to'
|
||||
export_to.attach_to_history = True
|
||||
export_to.backoffice_filefield_id = 'bo1'
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
|
||||
assert export_to.get_backoffice_filefield_options() == [('bo1', 'bo field 1', 'bo1')]
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
wf.add_status('Status2', 'st2')
|
||||
wf.store()
|
||||
|
||||
|
@ -995,7 +943,7 @@ def test_formdata_generated_document_in_private_history(pub):
|
|||
wf = Workflow(name='status')
|
||||
st0 = wf.add_status('Status0', 'st0')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model', id='_export_to')
|
||||
export_to.label = 'create doc'
|
||||
upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
|
||||
upload.fp = io.BytesIO()
|
||||
|
@ -1003,28 +951,19 @@ def test_formdata_generated_document_in_private_history(pub):
|
|||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.app_dir, None, upload)
|
||||
export_to.attach_to_history = True
|
||||
export_to.id = '_export_to'
|
||||
export_to.by = ['_submitter']
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
|
||||
st2 = wf.add_status('Status2', 'st2')
|
||||
|
||||
jump1 = ChoiceWorkflowStatusItem()
|
||||
jump1.id = '_jump1'
|
||||
jump1 = st0.add_action('choice', id='_jump1')
|
||||
jump1.label = 'Jump 1'
|
||||
jump1.by = ['_receiver']
|
||||
jump1.status = st1.id
|
||||
jump1.parent = st0
|
||||
st0.items.append(jump1)
|
||||
|
||||
jump2 = ChoiceWorkflowStatusItem()
|
||||
jump2.id = '_jump2'
|
||||
jump2 = st1.add_action('choice', id='_jump2')
|
||||
jump2.label = 'Jump 2'
|
||||
jump2.by = ['_receiver']
|
||||
jump2.status = st2.id
|
||||
jump2.parent = st1
|
||||
st1.items.append(jump2)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1075,20 +1014,14 @@ def test_formdata_empty_form_action(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
jump1 = ChoiceWorkflowStatusItem()
|
||||
jump1.id = '_jump1'
|
||||
jump1 = st1.add_action('choice', id='_jump1')
|
||||
jump1.label = 'Jump 1'
|
||||
jump1.by = ['_submitter']
|
||||
jump1.status = 'st2'
|
||||
jump1.parent = st1
|
||||
st1.items.append(jump1)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1117,14 +1050,11 @@ def test_formdata_form_file_download(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(fields.FileField(id='1', label='File', type='file', varname='yyy'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1166,8 +1096,7 @@ def test_formdata_workflow_form_prefill(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -1176,8 +1105,6 @@ def test_formdata_workflow_form_prefill(pub):
|
|||
id='1', label='blah', type='string', varname='yyy', prefill={'type': 'user', 'value': 'email'}
|
||||
)
|
||||
)
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1204,8 +1131,7 @@ def test_formdata_workflow_form_prefill_conditional_field(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -1229,8 +1155,6 @@ def test_formdata_workflow_form_prefill_conditional_field(pub):
|
|||
condition={'type': 'django', 'value': '1'},
|
||||
)
|
||||
)
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1257,8 +1181,7 @@ def test_formdata_workflow_form_prefill_checkbox(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -1272,8 +1195,6 @@ def test_formdata_workflow_form_prefill_checkbox(pub):
|
|||
id='2', label='blah2', type='bool', varname='zzz', prefill={'type': 'formula', 'value': 'True'}
|
||||
)
|
||||
)
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1313,8 +1234,7 @@ def test_formdata_workflow_form_prefill_autocomplete(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -1329,8 +1249,6 @@ def test_formdata_workflow_form_prefill_autocomplete(pub):
|
|||
prefill={'type': 'string', 'value': '{{ form_var_foo_raw }}'},
|
||||
),
|
||||
]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1387,18 +1305,14 @@ def test_formdata_workflow_many_forms(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
# first form
|
||||
display_form1 = FormWorkflowStatusItem()
|
||||
display_form1.id = '_x'
|
||||
display_form1 = st1.add_action('form', id='_x')
|
||||
display_form1.by = ['_submitter']
|
||||
display_form1.varname = 'xxx'
|
||||
display_form1.formdef = WorkflowFormFieldsFormDef(item=display_form1)
|
||||
display_form1.formdef.fields = [fields.StringField(id='1', label='blah1')]
|
||||
st1.items.append(display_form1)
|
||||
display_form1.parent = st1
|
||||
|
||||
# second form with live condition
|
||||
display_form2 = FormWorkflowStatusItem()
|
||||
display_form2.id = '_y'
|
||||
display_form2 = st1.add_action('form', id='_y')
|
||||
display_form2.by = ['_submitter']
|
||||
display_form2.varname = 'yyy'
|
||||
display_form2.formdef = WorkflowFormFieldsFormDef(item=display_form2)
|
||||
|
@ -1413,8 +1327,6 @@ def test_formdata_workflow_many_forms(pub):
|
|||
condition={'type': 'django', 'value': 'yyy_var_str == "xxx"'},
|
||||
),
|
||||
]
|
||||
st1.items.append(display_form2)
|
||||
display_form2.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1467,17 +1379,12 @@ def test_formdata_named_wscall(http_requests, pub):
|
|||
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '_comment'
|
||||
comment = st1.add_action('register-comment', id='_comment')
|
||||
comment.comment = 'Hello [webservice.hello_world.foo] World'
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st1.add_action('displaymsg')
|
||||
display.message = 'The form has been recorded and: X[webservice.hello_world.foo]Y'
|
||||
display.to = []
|
||||
st1.items.append(display)
|
||||
display.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1624,12 +1531,9 @@ def test_formdata_evolution_registercommenter_to(pub):
|
|||
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '_comment'
|
||||
comment = st1.add_action('register-comment', id='_comment')
|
||||
comment.comment = 'Hello World'
|
||||
comment.to = None
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -1713,29 +1617,20 @@ def test_formdata_evolution_registercommenter_to_with_attachment(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '1'
|
||||
comment = st1.add_action('register-comment', id='1')
|
||||
comment.comment = 'Hello all'
|
||||
comment.attachments = ['form_var_file1_raw']
|
||||
comment.to = None
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '2'
|
||||
comment = st1.add_action('register-comment', id='2')
|
||||
comment.comment = 'Hello role1'
|
||||
comment.attachments = ['form_var_file2_raw']
|
||||
comment.to = [role1.id]
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
|
||||
comment = RegisterCommenterWorkflowStatusItem()
|
||||
comment.id = '3'
|
||||
comment = st1.add_action('register-comment', id='3')
|
||||
comment.comment = 'Hello role2'
|
||||
comment.attachments = ['form_var_file3_raw']
|
||||
comment.to = [role2.id]
|
||||
st1.items.append(comment)
|
||||
comment.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from wcs.blocks import BlockDef
|
|||
from wcs.carddef import CardDef
|
||||
from wcs.data_sources import NamedDataSource
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -366,8 +366,7 @@ def test_field_live_select_content_on_workflow_form(pub, http_requests):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
# form displayed into the workflow
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = ['_submitter']
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
|
@ -386,8 +385,6 @@ def test_field_live_select_content_on_workflow_form(pub, http_requests):
|
|||
},
|
||||
),
|
||||
]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
wf.store()
|
||||
|
||||
# initial empty form
|
||||
|
|
|
@ -21,7 +21,6 @@ from wcs.qommon.management.commands.collectstatic import Command as CmdCollectSt
|
|||
from wcs.qommon.management.commands.migrate import Command as CmdMigrate
|
||||
from wcs.qommon.management.commands.migrate_schemas import Command as CmdMigrateSchemas
|
||||
from wcs.sql import cleanup_connection, get_connection_and_cursor
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowStatusItem
|
||||
|
||||
from .utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
@ -155,11 +154,9 @@ def test_trigger_jumps(pub):
|
|||
Workflow.wipe()
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump = st1.add_action('jump')
|
||||
jump.trigger = 'goto2'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
workflow.store()
|
||||
|
||||
|
|
|
@ -554,13 +554,9 @@ def test_get_formdefs_of_all_kinds(pub):
|
|||
|
||||
wf1 = Workflow(name='workflow with form fields formdef')
|
||||
st1 = wf1.add_status('Status1', 'st1')
|
||||
display_form1 = FormWorkflowStatusItem()
|
||||
display_form1 = st1.add_action('form')
|
||||
display_form1.formdef = WorkflowFormFieldsFormDef(item=display_form1)
|
||||
display_form1.parent = st1
|
||||
display_form2 = FormWorkflowStatusItem()
|
||||
display_form2.parent = st1
|
||||
st1.items.append(display_form1)
|
||||
st1.items.append(display_form2) # empty formdef
|
||||
st1.add_action('form') # empty formdef
|
||||
wf1.store()
|
||||
|
||||
wf2 = Workflow(name='workflow with variables fields formdef')
|
||||
|
@ -596,16 +592,13 @@ def test_pickle_2to3_conversion(pub):
|
|||
fields.StringField(id='bo0', varname='foo_bovar', type='string', label='bo variable'),
|
||||
]
|
||||
status = workflow.add_status('Status1')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_display_form'
|
||||
display_form = status.add_action('form', id='_display_form')
|
||||
display_form.by = []
|
||||
display_form.varname = 'blah'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(
|
||||
fields.StringField(id='1', label='Test', varname='str', type='string', required=True)
|
||||
)
|
||||
status.items.append(display_form)
|
||||
display_form.parent = status
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
|
|
@ -15,7 +15,6 @@ from wcs.qommon.http_request import HTTPRequest
|
|||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.misc import indent_xml as indent
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from .utilities import clean_temporary_pub, create_temporary_pub, get_app, login
|
||||
|
@ -130,12 +129,10 @@ def test_mail_template_in_use(pub, superuser):
|
|||
MailTemplate.wipe()
|
||||
workflow = Workflow(name='test workflow')
|
||||
st1 = workflow.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['_receiver']
|
||||
item.subject = 'Foobar'
|
||||
item.body = 'Hello'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.store()
|
||||
|
||||
mail_template = MailTemplate(name='test mail template')
|
||||
|
@ -170,12 +167,10 @@ def test_admin_workflow_edit(pub, superuser):
|
|||
|
||||
workflow = Workflow(name='test mail template')
|
||||
st1 = workflow.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['_receiver']
|
||||
item.subject = 'Foobar'
|
||||
item.body = 'Hello'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
@ -303,13 +298,11 @@ def test_workflow_send_mail_template_with_sql(superuser, emails):
|
|||
|
||||
workflow = Workflow(name='test mail template')
|
||||
st1 = workflow.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = 'xyz@localhost'
|
||||
item.subject = 'Foobar'
|
||||
item.body = 'Hello'
|
||||
item.mail_template = mail_template.slug
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -351,13 +344,11 @@ def test_workflow_send_mail_template_attachments(pub, superuser, emails):
|
|||
|
||||
workflow = Workflow(name='test mail template')
|
||||
st1 = workflow.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = 'xyz@localhost'
|
||||
item.subject = 'Foobar'
|
||||
item.body = 'Hello'
|
||||
item.mail_template = mail_template.slug
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
|
|
@ -31,7 +31,6 @@ from wcs.qommon.misc import (
|
|||
simplify,
|
||||
)
|
||||
from wcs.scripts import Script
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from .utilities import clean_temporary_pub, create_temporary_pub, get_app
|
||||
|
@ -444,9 +443,7 @@ def test_dict_from_prefix():
|
|||
def test_objects_repr():
|
||||
workflow = Workflow(name='wf')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
st1.items.append(jump)
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
|
||||
assert 'st1' in repr(st1)
|
||||
assert '_jump' in repr(jump)
|
||||
|
|
|
@ -27,8 +27,6 @@ from wcs.qommon.cron import CronJob
|
|||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.publisher import Tenant
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from .utilities import create_temporary_pub
|
||||
|
@ -490,7 +488,7 @@ def test_clean_models():
|
|||
def make_wf():
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model')
|
||||
export_to.label = 'test'
|
||||
upload = Upload('/foo/bar', content_type='application/vnd.oasis.opendocument.text')
|
||||
file_content = b'''PK\x03\x04\x14\x00\x00\x08\x00\x00\'l\x8eG^\xc62\x0c\'\x00'''
|
||||
|
@ -498,14 +496,8 @@ def test_clean_models():
|
|||
upload.fp.write(file_content)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile('models', 'a', upload)
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
export_to = ExportToModel() # empty model
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
sendmail = SendmailWorkflowStatusItem() # other item
|
||||
st1.items.append(sendmail)
|
||||
sendmail.parent = st1
|
||||
st1.add_action('export_to_model') # empty model
|
||||
st1.add_action('sendmail') # other item
|
||||
# export/import to get models stored in the expected way
|
||||
workflow.store()
|
||||
workflow = Workflow.import_from_xml_tree(
|
||||
|
|
|
@ -15,8 +15,7 @@ from wcs.formdef import FormDef
|
|||
from wcs.mail_templates import MailTemplate
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.misc import localstrftime
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import Workflow, WorkflowVariablesFieldsFormDef
|
||||
from wcs.wscalls import NamedWsCall
|
||||
|
||||
|
@ -672,15 +671,12 @@ def test_workflow_snapshot_restore_with_import_error(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [
|
||||
ItemField(id='1', label='Test', type='item', data_source={'type': 'unknown'})
|
||||
]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
wf.store()
|
||||
|
||||
assert pub.snapshot_class.count() == 1
|
||||
|
@ -744,7 +740,7 @@ def test_workflow_with_model_snapshot_browse(pub):
|
|||
shutil.rmtree(os.path.join(pub.app_dir, 'models'))
|
||||
workflow = Workflow(name='test')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model')
|
||||
export_to.label = 'test'
|
||||
upload = Upload('/foo/bar', content_type='application/vnd.oasis.opendocument.text')
|
||||
file_content = b'''PK\x03\x04\x14\x00\x00\x08\x00\x00\'l\x8eG^\xc62\x0c\'\x00'''
|
||||
|
@ -752,8 +748,6 @@ def test_workflow_with_model_snapshot_browse(pub):
|
|||
upload.fp.write(file_content)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile('models', 'tmp', upload)
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
|
||||
# export/import to get models stored in the expected way
|
||||
workflow.store()
|
||||
|
@ -811,13 +805,10 @@ def test_workflow_with_form_snapshot_browse(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(StringField(id='1', label='Test', type='string'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
wf.store()
|
||||
snapshot = pub.snapshot_class.select_object_history(wf)[0]
|
||||
|
||||
|
@ -894,7 +885,7 @@ def test_snaphost_workflow_status_item_comments(pub):
|
|||
workflow.add_status(name='baz')
|
||||
workflow.add_status(name='hop')
|
||||
global_action = workflow.add_global_action('Action', 'ac1')
|
||||
register_comment = global_action.append_item('register-comment')
|
||||
register_comment = global_action.add_action('register-comment')
|
||||
workflow.store()
|
||||
|
||||
app = login(get_app(pub))
|
||||
|
|
|
@ -14,8 +14,6 @@ from wcs.blocks import BlockDef
|
|||
from wcs.formdata import Evolution
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon import force_str
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowCriticalityLevel
|
||||
|
||||
|
@ -1328,11 +1326,8 @@ def test_is_at_endpoint(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf.store()
|
||||
assert [x.id for x in wf.get_endpoint_status()] == ['st2']
|
||||
|
@ -1588,11 +1583,8 @@ def test_actions_roles(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '1']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf.store()
|
||||
assert [x.id for x in wf.get_endpoint_status()] == ['st2']
|
||||
|
@ -1652,11 +1644,8 @@ def test_last_update_time(pub):
|
|||
wf = Workflow(name='test last update time')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -1921,19 +1910,13 @@ def test_view_performances(pub):
|
|||
workflow = Workflow(name='test perf wf %s' % i)
|
||||
for j in range(5):
|
||||
status = workflow.add_status('Status %d' % j, 'st%s' % j)
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable%s' % j
|
||||
commentable = status.add_action('commentable', id='_commentable%s' % j)
|
||||
commentable.by = [random.choice(roles).id, random.choice(roles).id]
|
||||
status.items.append(commentable)
|
||||
commentable.parent = status
|
||||
if j != 4:
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump%s' % j
|
||||
jump = status.add_action('jump', id='_jump%s' % j)
|
||||
jump.by = []
|
||||
jump.timeout = 5
|
||||
jump.status = 'st%s' % (j + 1)
|
||||
status.items.append(jump)
|
||||
jump.parent = status
|
||||
workflow.store()
|
||||
workflows.append(workflow)
|
||||
|
||||
|
|
|
@ -13,24 +13,8 @@ from wcs.formdef import FormDef
|
|||
from wcs.mail_templates import MailTemplate
|
||||
from wcs.qommon.form import UploadedFile
|
||||
from wcs.qommon.misc import indent_xml as indent
|
||||
from wcs.wf.attachment import AddAttachmentWorkflowStatusItem
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import ExportToModel
|
||||
from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.jump_on_submit import JumpOnSubmitWorkflowStatusItem
|
||||
from wcs.wf.profile import UpdateUserProfileStatusItem
|
||||
from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
|
||||
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.sms import SendSMSWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.workflows import (
|
||||
Workflow,
|
||||
WorkflowBackofficeFieldsFormDef,
|
||||
|
@ -80,11 +64,8 @@ def test_status_actions(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
assert_import_export_works(wf)
|
||||
|
||||
|
@ -122,12 +103,9 @@ def test_action_dispatch(pub):
|
|||
role.name = 'Test Role'
|
||||
role.store()
|
||||
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_x'
|
||||
dispatch = st1.add_action('dispatch', id='_x')
|
||||
dispatch.role_id = 5
|
||||
dispatch.role_key = 'plop'
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
||||
|
@ -170,11 +148,8 @@ def test_status_actions_named_role(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['logged-users']
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
assert_import_export_works(wf)
|
||||
|
||||
|
@ -189,11 +164,8 @@ def test_status_actions_named_existing_role(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [2]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert re.findall(
|
||||
|
@ -231,11 +203,8 @@ def test_status_actions_named_missing_role(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = [3]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
assert_import_export_works(wf)
|
||||
|
||||
|
@ -273,13 +242,10 @@ def test_display_form_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(StringField(label='Test', type='string'))
|
||||
display_form.formdef.fields.append(StringField(label='Test2', type='string'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
# formdef.max_field_id is recalculated when importing a FormWorkflowStatusItem
|
||||
|
@ -295,7 +261,7 @@ def test_export_to_model_action(pub):
|
|||
wf.store()
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
export_to = ExportToModel()
|
||||
export_to = st1.add_action('export_to_model')
|
||||
export_to.label = 'test'
|
||||
upload = Upload('/foo/bar', content_type='application/vnd.oasis.opendocument.text')
|
||||
file_content = b'''PK\x03\x04\x14\x00\x00\x08\x00\x00\'l\x8eG^\xc62\x0c\'\x00'''
|
||||
|
@ -303,8 +269,6 @@ def test_export_to_model_action(pub):
|
|||
upload.fp.write(file_content)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.APP_DIR, None, upload)
|
||||
st1.items.append(export_to)
|
||||
export_to.parent = st1
|
||||
|
||||
assert wf.possible_status[0].items[0].model_file.base_filename == 'bar'
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
@ -312,7 +276,8 @@ def test_export_to_model_action(pub):
|
|||
assert wf2.possible_status[0].items[0].model_file.get_file().read() == file_content
|
||||
|
||||
# and test with an empty file
|
||||
export_to = ExportToModel()
|
||||
st1.items = []
|
||||
export_to = st1.add_action('export_to_model')
|
||||
export_to.label = 'test'
|
||||
upload = Upload('/foo/bar', content_type='text/rtf')
|
||||
file_content = b''
|
||||
|
@ -320,8 +285,6 @@ def test_export_to_model_action(pub):
|
|||
upload.fp.write(file_content)
|
||||
upload.fp.seek(0)
|
||||
export_to.model_file = UploadedFile(pub.APP_DIR, None, upload)
|
||||
st1.items = [export_to]
|
||||
export_to.parent = st1
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].model_file.get_file().read() == file_content
|
||||
|
||||
|
@ -351,15 +314,12 @@ def test_jump_action(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
wf.add_status('Status2', 'st2')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.condition = {'type': 'python', 'value': '"foo"'}
|
||||
jump.trigger = 'bar'
|
||||
jump.timeout = 1200
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].condition == {'type': 'python', 'value': '"foo"'}
|
||||
|
@ -385,12 +345,9 @@ def test_commentable_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
commentable.button_label = None
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].button_label is None
|
||||
|
@ -425,16 +382,13 @@ def test_wscall_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
wscall = WebserviceCallStatusItem()
|
||||
wscall.id = '_wscall'
|
||||
wscall = st1.add_action('webservice_call', id='_wscall')
|
||||
wscall.url = 'http://test/'
|
||||
wscall.varname = 'varname'
|
||||
wscall.post = False
|
||||
wscall.request_signature_key = 'key'
|
||||
wscall.post_data = {'one': '1', 'two': '=2', 'good:name': 'ok', 'empty': ''}
|
||||
wscall.qs_data = {'one': '2', 'two': '=3', 'good:name': 'ok', 'empty': ''}
|
||||
st1.items.append(wscall)
|
||||
wscall.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
wscall2 = wf2.possible_status[0].items[0]
|
||||
|
@ -451,12 +405,9 @@ def test_backoffice_info_text(pub):
|
|||
st1 = wf.add_status('Status1', 'st1')
|
||||
st1.backoffice_info_text = '<p>Foo</p>'
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable.id = '_commentable'
|
||||
commentable = st1.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
commentable.backoffice_info_text = '<p>Bar</p>'
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].backoffice_info_text == '<p>Foo</p>'
|
||||
|
@ -473,11 +424,8 @@ def test_global_actions(pub):
|
|||
ac1 = wf.add_global_action('Action', 'ac1')
|
||||
ac1.backoffice_info_text = '<p>Foo</p>'
|
||||
|
||||
add_to_journal = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal.id = '_add_to_journal'
|
||||
add_to_journal = ac1.add_action('register-comment', id='_add_to_journal')
|
||||
add_to_journal.comment = 'HELLO WORLD'
|
||||
ac1.items.append(add_to_journal)
|
||||
add_to_journal.parent = ac1
|
||||
|
||||
trigger = ac1.triggers[0]
|
||||
assert trigger.key == 'manual'
|
||||
|
@ -498,18 +446,12 @@ def test_register_comment_to(pub):
|
|||
wf = Workflow(name='global actions')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
add_to_journal1 = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal1.id = '_add_to_journal1'
|
||||
add_to_journal1 = st1.add_action('register-comment', id='_add_to_journal1')
|
||||
add_to_journal1.comment = 'HELLO WORLD'
|
||||
st1.items.append(add_to_journal1)
|
||||
add_to_journal1.parent = st1
|
||||
|
||||
add_to_journal2 = RegisterCommenterWorkflowStatusItem()
|
||||
add_to_journal2.id = '_add_to_journal2'
|
||||
add_to_journal2 = st1.add_action('register-comment', id='_add_to_journal2')
|
||||
add_to_journal2.comment = 'OLA MUNDO'
|
||||
add_to_journal2.to = [role.id]
|
||||
st1.items.append(add_to_journal2)
|
||||
add_to_journal2.parent = st1
|
||||
assert wf.possible_status[0].items[0].to is None
|
||||
assert wf.possible_status[0].items[1].to == [role.id]
|
||||
|
||||
|
@ -545,14 +487,11 @@ def test_complex_dispatch_action(pub):
|
|||
role2.name = 'Test Role 2'
|
||||
role2.store()
|
||||
|
||||
dispatch = DispatchWorkflowStatusItem()
|
||||
dispatch.id = '_dispatch'
|
||||
dispatch = st1.add_action('dispatch', id='_dispatch')
|
||||
dispatch.role_key = '_receiver'
|
||||
dispatch.dispatch_type = 'automatic'
|
||||
dispatch.variable = 'plop'
|
||||
dispatch.rules = [{'value': 'a', 'role_id': role1.id}, {'value': 'b', 'role_id': role2.id}]
|
||||
st1.items.append(dispatch)
|
||||
dispatch.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].variable == dispatch.variable
|
||||
|
@ -591,11 +530,9 @@ def test_display_message_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display = DisplayMessageWorkflowStatusItem()
|
||||
display = st1.add_action('displaymsg')
|
||||
display.message = 'hey'
|
||||
display.to = ['_submitter', '1']
|
||||
st1.items.append(display)
|
||||
display.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
assert wf2.possible_status[0].items[0].message == display.message
|
||||
|
@ -609,10 +546,8 @@ def test_sendmail_other_destination(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
sendmail = SendmailWorkflowStatusItem()
|
||||
sendmail = st1.add_action('sendmail')
|
||||
sendmail.to = ['_submitter']
|
||||
st1.items.append(sendmail)
|
||||
sendmail.parent = st1
|
||||
|
||||
pub.role_class.wipe()
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
@ -634,9 +569,7 @@ def test_sendmail_attachments(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
sendmail = SendmailWorkflowStatusItem()
|
||||
st1.items.append(sendmail)
|
||||
sendmail.parent = st1
|
||||
sendmail = st1.add_action('sendmail')
|
||||
|
||||
sendmail.attachments = ['form_var_file_raw', 'form_fbo1']
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
@ -651,11 +584,9 @@ def test_sms(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
sendsms = SendSMSWorkflowStatusItem()
|
||||
sendsms = st1.add_action('sendsms')
|
||||
sendsms.to = ['0123456789', '']
|
||||
sendsms.body = 'hello'
|
||||
st1.items.append(sendsms)
|
||||
sendsms.parent = st1
|
||||
|
||||
pub.role_class.wipe()
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
@ -718,11 +649,8 @@ def test_profile_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
item = UpdateUserProfileStatusItem()
|
||||
item.id = '_item'
|
||||
item = st1.add_action('update_user_profile', id='_item')
|
||||
item.fields = [{'field_id': '__email', 'value': '=form_var_foo'}]
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
item2 = wf2.possible_status[0].items[0]
|
||||
|
@ -733,15 +661,12 @@ def test_attachment_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
item = AddAttachmentWorkflowStatusItem()
|
||||
item.id = '_foo'
|
||||
item = st1.add_action('addattachment', id='_foo')
|
||||
item.document_type = {
|
||||
'id': '_audio',
|
||||
'label': 'Sound files',
|
||||
'mimetypes': ['audio/*'],
|
||||
}
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
item2 = wf2.possible_status[0].items[0]
|
||||
|
@ -756,11 +681,8 @@ def test_set_backoffice_fields_action(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
item = SetBackofficeFieldsWorkflowStatusItem()
|
||||
item.id = '_item'
|
||||
item = st1.add_action('set-backoffice-fields', id='_item')
|
||||
item.fields = [{'field_id': 'bo1', 'value': '=form_var_foo'}]
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
item2 = wf2.possible_status[0].items[0]
|
||||
|
@ -771,11 +693,8 @@ def test_set_backoffice_fields_action_boolean(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
item = SetBackofficeFieldsWorkflowStatusItem()
|
||||
item.id = '_item'
|
||||
item = st1.add_action('set-backoffice-fields', id='_item')
|
||||
item.fields = [{'field_id': 'bo1', 'value': 'True'}]
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
item2 = wf2.possible_status[0].items[0]
|
||||
|
@ -786,9 +705,7 @@ def test_action_condition(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
sendmail = SendmailWorkflowStatusItem()
|
||||
st1.items.append(sendmail)
|
||||
sendmail.parent = st1
|
||||
sendmail = st1.add_action('sendmail')
|
||||
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
||||
|
@ -814,36 +731,24 @@ def test_create_formdata(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Resubmit')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_resubmit'
|
||||
jump = st1.add_action('choice', id='_resubmit')
|
||||
jump.label = 'Resubmit'
|
||||
jump.by = ['_submitter']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata.id = '_create_formdata'
|
||||
create_formdata = st2.add_action('create_formdata', id='_create_formdata')
|
||||
create_formdata.varname = 'resubmitted'
|
||||
create_formdata.formdef_slug = target_formdef.url_name
|
||||
create_formdata.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
]
|
||||
create_formdata.parent = st2
|
||||
st2.items.append(create_formdata)
|
||||
|
||||
redirect = RedirectToUrlWorkflowStatusItem()
|
||||
redirect.id = '_redirect'
|
||||
redirect = st2.add_action('redirect_to_url', id='_redirect')
|
||||
redirect.url = '{{ form_links_resubmitted.form_url }}'
|
||||
redirect.parent = st2
|
||||
st2.items.append(redirect)
|
||||
|
||||
jump = JumpOnSubmitWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st2.add_action('jumponsubmit', id='_jump')
|
||||
jump.status = st1.id
|
||||
jump.parent = st2
|
||||
st2.items.append(jump)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -866,22 +771,15 @@ def test_external_workflow(pub):
|
|||
st1 = wf.add_status('New')
|
||||
st2 = wf.add_status('Call external workflow')
|
||||
|
||||
jump = ChoiceWorkflowStatusItem()
|
||||
jump.id = '_external'
|
||||
jump = st1.add_action('choice', id='_external')
|
||||
jump.label = 'Cleanup'
|
||||
jump.by = ['_submitter']
|
||||
jump.status = st2.id
|
||||
jump.parent = st1
|
||||
st1.items.append(jump)
|
||||
|
||||
external_workflow = ExternalWorkflowGlobalAction()
|
||||
external_workflow.id = '_external_workflow'
|
||||
external_workflow = st2.add_action('external_workflow_global_action', id='_external_workflow')
|
||||
external_workflow.slug = 'formdef:%s' % target_formdef.url_name
|
||||
external_workflow.event = trigger.id
|
||||
|
||||
external_workflow.parent = st2
|
||||
st2.items.append(external_workflow)
|
||||
|
||||
wf.store()
|
||||
assert_import_export_works(wf, include_id=True)
|
||||
|
||||
|
@ -894,11 +792,9 @@ def test_worklow_with_mail_template(pub):
|
|||
|
||||
wf = Workflow(name='test mail template')
|
||||
st1 = wf.add_status('Status1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['_receiver']
|
||||
item.mail_template = mail_template.slug
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
wf.store()
|
||||
assert_import_export_works(wf, include_id=True)
|
||||
|
||||
|
@ -914,12 +810,9 @@ def test_worklow_with_mail_template(pub):
|
|||
def test_workflow_with_unknown_data_source(pub):
|
||||
wf1 = Workflow(name='status')
|
||||
st1 = wf1.add_status('Status1', 'st1')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [StringField(label='Test', type='string', data_source={'type': 'foobar'})]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf2 = Workflow(name='variables')
|
||||
wf2.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf2)
|
||||
|
@ -1012,12 +905,9 @@ def test_workflow_with_block(pub):
|
|||
|
||||
wf1 = Workflow(name='status')
|
||||
st1 = wf1.add_status('Status1', 'st1')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [BlockField(label='foo', type='block:foobar')]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
wf2 = Workflow(name='variables')
|
||||
wf2.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf2)
|
||||
|
@ -1069,8 +959,7 @@ def test_import_workflow_multiple_errors(pub):
|
|||
|
||||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [
|
||||
BlockField(id='1', type='block:foobar1'),
|
||||
|
@ -1079,32 +968,20 @@ def test_import_workflow_multiple_errors(pub):
|
|||
StringField(id='4', type='string', data_source={'type': 'carddef:unknown1'}),
|
||||
StringField(id='5', type='foobazz1'),
|
||||
]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
dispatch1 = DispatchWorkflowStatusItem()
|
||||
dispatch1.id = '_x1'
|
||||
dispatch1 = st1.add_action('dispatch', id='_x')
|
||||
dispatch1.role_id = 'unknown-role1'
|
||||
dispatch1.role_key = 'plop'
|
||||
st1.items.append(dispatch1)
|
||||
dispatch1.parent = st1
|
||||
dispatch2 = DispatchWorkflowStatusItem()
|
||||
dispatch2.id = '_x2'
|
||||
dispatch2 = st1.add_action('dispatch', id='_x2')
|
||||
dispatch2.role_id = 'unknown-role2'
|
||||
dispatch2.role_key = 'plop'
|
||||
st1.items.append(dispatch2)
|
||||
dispatch2.parent = st1
|
||||
|
||||
item1 = SendmailWorkflowStatusItem()
|
||||
item1 = st1.add_action('sendmail')
|
||||
item1.to = ['_receiver']
|
||||
item1.mail_template = 'unknown-mt-1'
|
||||
st1.items.append(item1)
|
||||
item1.parent = st1
|
||||
item2 = SendmailWorkflowStatusItem()
|
||||
item2 = st1.add_action('sendmail')
|
||||
item2.to = ['_receiver']
|
||||
item2.mail_template = 'unknown-mt-2'
|
||||
st1.items.append(item2)
|
||||
item2.parent = st1
|
||||
|
||||
wf.variables_formdef = WorkflowVariablesFieldsFormDef(workflow=wf)
|
||||
wf.variables_formdef.fields = [
|
||||
|
|
|
@ -49,23 +49,16 @@ from wcs.qommon.form import Form, UploadedFile, UploadValidationError
|
|||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.ident.password_accounts import PasswordAccount
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.aggregation_email import (
|
||||
AggregationEmail,
|
||||
AggregationEmailWorkflowStatusItem,
|
||||
send_aggregation_emails,
|
||||
)
|
||||
from wcs.wf.aggregation_email import AggregationEmail, send_aggregation_emails
|
||||
from wcs.wf.anonymise import AnonymiseWorkflowStatusItem
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.choice import ChoiceWorkflowStatusItem
|
||||
from wcs.wf.comment import CommentableWorkflowStatusItem
|
||||
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.wf.criticality import MODE_DEC, MODE_INC, MODE_SET, ModifyCriticalityWorkflowStatusItem
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.display_message import DisplayMessageWorkflowStatusItem
|
||||
from wcs.wf.export_to_model import ExportToModel, transform_to_pdf
|
||||
from wcs.wf.external_workflow import ManyExternalCallsPart
|
||||
from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
|
||||
from wcs.wf.form import WorkflowFormFieldsFormDef
|
||||
from wcs.wf.geolocate import GeolocateWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem, _apply_timeouts
|
||||
from wcs.wf.profile import UpdateUserProfileStatusItem
|
||||
|
@ -74,9 +67,7 @@ from wcs.wf.register_comment import JournalEvolutionPart, RegisterCommenterWorkf
|
|||
from wcs.wf.remove import RemoveWorkflowStatusItem
|
||||
from wcs.wf.remove_tracking_code import RemoveTrackingCodeWorkflowStatusItem
|
||||
from wcs.wf.roles import AddRoleWorkflowStatusItem, RemoveRoleWorkflowStatusItem
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.sms import SendSMSWorkflowStatusItem
|
||||
from wcs.wf.timeout_jump import TimeoutWorkflowStatusItem
|
||||
from wcs.wf.wscall import WebserviceCallStatusItem
|
||||
from wcs.workflows import (
|
||||
AbortActionException,
|
||||
|
@ -159,13 +150,10 @@ def test_get_json_export_dict(pub):
|
|||
st2 = workflow.add_status('Status2', 'st2')
|
||||
st2.forced_endpoint = True
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = 0.1
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.roles['_other'] = 'Other Function'
|
||||
root = workflow.get_json_export_dict()
|
||||
|
@ -190,15 +178,13 @@ def test_action_repr(pub):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
assert repr(jump) # no crash when not attached to status
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = 0.1
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
action = workflow.add_global_action('Timeout')
|
||||
criticality = action.append_item('modify_criticality')
|
||||
criticality = action.add_action('modify_criticality')
|
||||
workflow.store()
|
||||
with open(workflow.get_object_filename(), 'rb') as fd:
|
||||
# make sure parent relations are not stored in pickles
|
||||
|
@ -1089,21 +1075,15 @@ def test_stop_on_remove(two_pubs, emails):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
# sendmail + remove + sendmail
|
||||
mail1 = SendmailWorkflowStatusItem()
|
||||
mail1 = st1.add_action('sendmail')
|
||||
mail1.to = ['bar@localhost']
|
||||
mail1.subject = 'Foobar'
|
||||
mail1.body = 'email body'
|
||||
st1.items.append(mail1)
|
||||
mail1.parent = st1
|
||||
remove = RemoveWorkflowStatusItem()
|
||||
st1.items.append(remove)
|
||||
remove.parent = st1
|
||||
mail2 = SendmailWorkflowStatusItem()
|
||||
st1.add_action('remove')
|
||||
mail2 = st1.add_action('sendmail')
|
||||
mail2.to = ['bar@localhost']
|
||||
mail2.subject = 'Foobar2'
|
||||
mail2.body = 'email body 2'
|
||||
st1.items.append(mail2)
|
||||
mail2.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -1466,9 +1446,7 @@ def test_register_comment_to(pub):
|
|||
assert formdata.status == 'wf-st1'
|
||||
formdata.store()
|
||||
|
||||
register_commenter = RegisterCommenterWorkflowStatusItem()
|
||||
register_commenter.parent = st1
|
||||
st1.items.append(register_commenter)
|
||||
register_commenter = st1.add_action('register-comment')
|
||||
|
||||
def display_parts():
|
||||
formdata.evolution[-1]._display_parts = None # invalidate cache
|
||||
|
@ -1526,9 +1504,7 @@ def test_register_comment_to(pub):
|
|||
'<p>to-submitter</p>',
|
||||
'<p>to-role-or-submitter</p>',
|
||||
]
|
||||
register_commenter2 = RegisterCommenterWorkflowStatusItem()
|
||||
register_commenter2.parent = st1
|
||||
st1.items.append(register_commenter2)
|
||||
register_commenter2 = st1.add_action('register-comment')
|
||||
register_commenter2.comment = 'd2'
|
||||
register_commenter2.to = [role.id, '_submitter']
|
||||
user.roles = [role.id, role2.id]
|
||||
|
@ -1577,9 +1553,7 @@ def test_register_comment_to_with_attachment(pub):
|
|||
assert formdata.status == 'wf-st1'
|
||||
pub.substitutions.feed(formdata)
|
||||
|
||||
register_commenter = RegisterCommenterWorkflowStatusItem()
|
||||
register_commenter.parent = st1
|
||||
st1.items.append(register_commenter)
|
||||
register_commenter = st1.add_action('register-comment')
|
||||
|
||||
def display_parts():
|
||||
formdata.evolution[-1]._display_parts = None # invalidate cache
|
||||
|
@ -2447,13 +2421,10 @@ def test_timeout(two_pubs):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = 30 * 60 # 30 minutes
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2516,13 +2487,10 @@ def test_timeout_with_humantime_template(two_pubs):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = '{{ 30 }} minutes'
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2598,12 +2566,9 @@ def test_legacy_timeout(pub):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
|
||||
jump = TimeoutWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('timeout', id='_jump')
|
||||
jump.timeout = 30 * 60 # 30 minutes
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2630,17 +2595,12 @@ def test_timeout_then_remove(two_pubs):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = 30 * 60 # 30 minutes
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
remove = RemoveWorkflowStatusItem()
|
||||
st2.items.append(remove)
|
||||
remove.parent = st2
|
||||
st2.add_action('remove')
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2669,14 +2629,11 @@ def test_timeout_with_mark(two_pubs):
|
|||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.timeout = 30 * 60 # 30 minutes
|
||||
jump.status = 'st2'
|
||||
jump.set_marker_on_status = True
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2710,13 +2667,10 @@ def test_jump_missing_previous_mark(two_pubs):
|
|||
workflow = Workflow(name='jump-mark')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.status = '_previous'
|
||||
jump.timeout = 30 * 60 # 30 minutes
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -2911,14 +2865,11 @@ def test_display_form(two_pubs):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(StringField(id='1', label='Test', type='string'))
|
||||
display_form.formdef.fields.append(DateField(id='2', label='Date', type='date', varname='date'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
form = Form(action='#', use_tokens=False)
|
||||
display_form.fill_form(form, formdata, None)
|
||||
|
@ -2966,19 +2917,14 @@ def test_display_form_and_comment(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.by = [role.id]
|
||||
display_form.id = '_x'
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields.append(CommentField(id='1', label='Test', type='comment'))
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
commentable = CommentableWorkflowStatusItem()
|
||||
commentable = st1.add_action('commentable')
|
||||
commentable.by = [role.id]
|
||||
st1.items.append(commentable)
|
||||
commentable.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -2999,13 +2945,10 @@ def test_display_form_migration(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
display_form = FormWorkflowStatusItem()
|
||||
display_form.id = '_x'
|
||||
display_form = st1.add_action('form', id='_x')
|
||||
display_form.varname = 'xxx'
|
||||
display_form.formdef = WorkflowFormFieldsFormDef(item=display_form)
|
||||
display_form.formdef.fields = [ItemField(id='1', label='Test', type='item')]
|
||||
st1.items.append(display_form)
|
||||
display_form.parent = st1
|
||||
|
||||
display_form.formdef.fields[0].show_as_radio = True
|
||||
wf.store()
|
||||
|
@ -3030,18 +2973,12 @@ def test_choice_button_no_label(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice = st1.add_action('choice', id='_x')
|
||||
choice.by = [role.id]
|
||||
choice.id = '_x'
|
||||
st1.items.append(choice)
|
||||
choice.parent = st1
|
||||
|
||||
choice2 = ChoiceWorkflowStatusItem()
|
||||
choice2 = st1.add_action('choice', id='_x2')
|
||||
choice2.label = 'TEST'
|
||||
choice2.by = [role.id]
|
||||
choice2.id = '_x2'
|
||||
st1.items.append(choice2)
|
||||
choice2.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3075,12 +3012,9 @@ def test_choice_button_template_label(pub):
|
|||
wf = Workflow(name='status')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice = st1.add_action('choice', id='_x')
|
||||
choice.label = '{{ "a"|add:"b" }}'
|
||||
choice.by = [role.id]
|
||||
choice.id = '_x'
|
||||
st1.items.append(choice)
|
||||
choice.parent = st1
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -3109,11 +3043,8 @@ def test_workflow_role_type_migration(pub):
|
|||
workflow = Workflow(name='role migration')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = [1, 2]
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
workflow.store()
|
||||
|
||||
|
@ -3180,9 +3111,7 @@ def test_workflow_display_message_to(pub):
|
|||
formdata = formdef.data_class()()
|
||||
formdata.status = 'wf-st1'
|
||||
|
||||
display_message = DisplayMessageWorkflowStatusItem()
|
||||
display_message.parent = st1
|
||||
st1.items.append(display_message)
|
||||
display_message = st1.add_action('displaymsg')
|
||||
|
||||
display_message.message = 'all'
|
||||
display_message.to = None
|
||||
|
@ -3231,9 +3160,7 @@ def test_workflow_display_message_to(pub):
|
|||
assert formdata.get_workflow_messages(user=pub._request._user) == []
|
||||
|
||||
display_message.message = 'd1'
|
||||
display_message2 = DisplayMessageWorkflowStatusItem()
|
||||
display_message2.parent = st1
|
||||
st1.items.append(display_message2)
|
||||
display_message2 = st1.add_action('displaymsg')
|
||||
display_message2.message = 'd2'
|
||||
display_message2.to = [role.id, '_submitter']
|
||||
assert formdata.get_workflow_messages(user=pub._request._user) == ['d2']
|
||||
|
@ -3265,8 +3192,7 @@ def test_workflow_display_message_line_details(pub):
|
|||
def test_choice_line_details(pub):
|
||||
workflow = Workflow(name='choice')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice.parent = st1
|
||||
choice = st1.add_action('choice')
|
||||
|
||||
assert choice.get_line_details() == 'not completed'
|
||||
|
||||
|
@ -3305,12 +3231,10 @@ def test_workflow_roles(pub, emails):
|
|||
|
||||
workflow = Workflow(name='wf roles')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['_receiver', '_other']
|
||||
item.subject = 'Foobar'
|
||||
item.body = 'Hello'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
workflow.roles['_other'] = 'Other Function'
|
||||
workflow.store()
|
||||
|
||||
|
@ -3400,11 +3324,9 @@ def test_geolocate_action_enable_geolocation(two_pubs):
|
|||
|
||||
workflow = Workflow(name='wf')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
item = GeolocateWorkflowStatusItem()
|
||||
item = st1.add_action('geolocate')
|
||||
item.method = 'address_string'
|
||||
item.address_string = '{{form_var_string}}, paris, france'
|
||||
item.parent = st1
|
||||
st1.items.append(item)
|
||||
workflow.store()
|
||||
|
||||
formdef.change_workflow(workflow)
|
||||
|
@ -3428,11 +3350,9 @@ def test_geolocate_action_enable_geolocation(two_pubs):
|
|||
formdef.store()
|
||||
assert not formdef.geolocations
|
||||
|
||||
item = GeolocateWorkflowStatusItem()
|
||||
item = st1.add_action('geolocate')
|
||||
item.method = 'address_string'
|
||||
item.address_string = '{{form_var_string}}, paris, france'
|
||||
item.parent = st1
|
||||
st1.items.append(item)
|
||||
workflow.store()
|
||||
get_response().process_after_jobs()
|
||||
|
||||
|
@ -4111,7 +4031,7 @@ def test_global_timeouts(two_pubs, formdef_class):
|
|||
WorkflowCriticalityLevel(name='red'),
|
||||
]
|
||||
action = workflow.add_global_action('Timeout Test')
|
||||
action.append_item('modify_criticality')
|
||||
action.add_action('modify_criticality')
|
||||
trigger = action.append_trigger('timeout')
|
||||
trigger.anchor = 'creation'
|
||||
workflow.store()
|
||||
|
@ -4382,7 +4302,7 @@ def test_global_timeouts_latest_arrival(two_pubs):
|
|||
WorkflowCriticalityLevel(name='red'),
|
||||
]
|
||||
action = workflow.add_global_action('Timeout Test')
|
||||
action.append_item('modify_criticality')
|
||||
action.add_action('modify_criticality')
|
||||
trigger = action.append_trigger('timeout')
|
||||
trigger.anchor = 'latest-arrival'
|
||||
trigger.anchor_status_latest = 'wf-new'
|
||||
|
@ -5983,10 +5903,7 @@ def test_workflow_jump_condition_migration(pub):
|
|||
workflow = Workflow(name='jump condition migration')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
workflow.store()
|
||||
|
||||
reloaded_workflow = Workflow.get(workflow.id)
|
||||
|
@ -6011,11 +5928,8 @@ def test_workflow_action_condition(two_pubs):
|
|||
user.roles = [role.id]
|
||||
user.store()
|
||||
|
||||
choice = ChoiceWorkflowStatusItem()
|
||||
choice = st1.add_action('choice', id='_x')
|
||||
choice.by = [role.id]
|
||||
choice.id = '_x'
|
||||
st1.items.append(choice)
|
||||
choice.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -6105,12 +6019,10 @@ def test_aggregation_email(pub, emails):
|
|||
|
||||
workflow = Workflow(name='aggregation-email')
|
||||
workflow.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
aggregation = AggregationEmailWorkflowStatusItem()
|
||||
aggregation.parent = workflow.possible_status[1]
|
||||
aggregation = workflow.possible_status[1].add_action('aggregationemail', prepend=True)
|
||||
assert aggregation.get_line_details() == 'not completed'
|
||||
aggregation.to = [role.id]
|
||||
assert aggregation.get_line_details() == 'to foobar'
|
||||
workflow.possible_status[1].items.insert(0, aggregation)
|
||||
workflow.store()
|
||||
|
||||
FormDef.wipe()
|
||||
|
@ -6168,7 +6080,7 @@ def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
|||
external_wf = Workflow(name='External Workflow')
|
||||
st1 = external_wf.add_status(name='New')
|
||||
action = external_wf.add_global_action('Delete', 'delete')
|
||||
action.append_item('remove')
|
||||
action.add_action('remove')
|
||||
trigger = action.append_trigger('webservice')
|
||||
trigger.identifier = 'delete'
|
||||
external_wf.store()
|
||||
|
@ -6191,28 +6103,21 @@ def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
|||
|
||||
wf = Workflow(name='External actions')
|
||||
st1 = wf.add_status('Create external formdata')
|
||||
create_formdata = CreateFormdataWorkflowStatusItem()
|
||||
create_formdata = st1.add_action('create_formdata', id='_create_form')
|
||||
create_formdata.label = 'create linked form'
|
||||
create_formdata.formdef_slug = external_formdef.url_name
|
||||
create_formdata.varname = 'created_form'
|
||||
create_formdata.id = '_create_form'
|
||||
mappings = [Mapping(field_id='0', expression='{{ form_var_string }}')]
|
||||
create_formdata.mappings = mappings
|
||||
create_formdata.parent = st1
|
||||
|
||||
create_carddata = CreateCarddataWorkflowStatusItem()
|
||||
create_carddata = st1.add_action('create_carddata', id='_create_card')
|
||||
create_carddata.label = 'create linked card'
|
||||
create_carddata.formdef_slug = external_carddef.url_name
|
||||
create_carddata.varname = 'created_card'
|
||||
create_carddata.id = '_create_card'
|
||||
create_carddata.mappings = mappings
|
||||
create_carddata.parent = st1
|
||||
|
||||
st1.items.append(create_formdata)
|
||||
st1.items.append(create_carddata)
|
||||
|
||||
global_action = wf.add_global_action('Delete external linked object', 'delete')
|
||||
action = global_action.append_item('external_workflow_global_action')
|
||||
action = global_action.add_action('external_workflow_global_action')
|
||||
action.slug = 'formdef:%s' % external_formdef.url_name
|
||||
action.trigger_id = 'action:%s' % trigger.identifier
|
||||
wf.store()
|
||||
|
@ -6275,14 +6180,14 @@ def test_call_external_workflow_with_data_sourced_object(two_pubs, admin_user):
|
|||
StringField(id='bo0', varname='bo', type='string', label='bo variable'),
|
||||
]
|
||||
update_action = carddef_wf.add_global_action('Update', 'ac1')
|
||||
update_action.append_item('set-backoffice-fields')
|
||||
update_action.add_action('set-backoffice-fields')
|
||||
setbo = update_action.items[0]
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': '{{ form_var_bo|default:"0"|add:1 }}'}]
|
||||
trigger = update_action.append_trigger('webservice')
|
||||
trigger.identifier = 'update'
|
||||
|
||||
delete = carddef_wf.add_global_action('Delete', 'delete')
|
||||
delete.append_item('remove')
|
||||
delete.add_action('remove')
|
||||
trigger = delete.append_trigger('webservice')
|
||||
trigger.identifier = 'delete'
|
||||
carddef_wf.store()
|
||||
|
@ -6305,12 +6210,12 @@ def test_call_external_workflow_with_data_sourced_object(two_pubs, admin_user):
|
|||
wf.add_status('Action')
|
||||
|
||||
update_global_action = wf.add_global_action('Update linked object data')
|
||||
update_action = update_global_action.append_item('external_workflow_global_action')
|
||||
update_action = update_global_action.add_action('external_workflow_global_action')
|
||||
update_action.slug = 'carddef:%s' % carddef.url_name
|
||||
update_action.trigger_id = 'action:update'
|
||||
|
||||
delete_global_action = wf.add_global_action('Delete external linked object', 'delete')
|
||||
delete_action = delete_global_action.append_item('external_workflow_global_action')
|
||||
delete_action = delete_global_action.add_action('external_workflow_global_action')
|
||||
delete_action.slug = 'carddef:%s' % carddef.url_name
|
||||
delete_action.trigger_id = 'action:delete'
|
||||
wf.store()
|
||||
|
@ -6366,7 +6271,7 @@ def test_call_external_workflow_with_parent_object(pub):
|
|||
StringField(id='bo0', varname='bo', type='string', label='bo variable'),
|
||||
]
|
||||
increment_global_action = carddef_wf.add_global_action('Update')
|
||||
increment_global_action.append_item('set-backoffice-fields')
|
||||
increment_global_action.add_action('set-backoffice-fields')
|
||||
setbo = increment_global_action.items[0]
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': '{{ form_var_bo|default:"0"|add:1 }}'}]
|
||||
trigger = increment_global_action.append_trigger('webservice')
|
||||
|
@ -6392,7 +6297,7 @@ def test_call_external_workflow_with_parent_object(pub):
|
|||
wf.add_status('Action')
|
||||
|
||||
update_global_action = wf.add_global_action('Update linked object data')
|
||||
update_action = update_global_action.append_item('external_workflow_global_action')
|
||||
update_action = update_global_action.add_action('external_workflow_global_action')
|
||||
update_action.slug = 'carddef:%s' % carddef.url_name
|
||||
update_action.trigger_id = 'action:update'
|
||||
wf.store()
|
||||
|
@ -6450,7 +6355,7 @@ def test_call_external_workflow_use_caller_variable(pub):
|
|||
StringField(id='bo0', varname='bo', type='string', label='bo variable'),
|
||||
]
|
||||
global_action = carddef_wf.add_global_action('Update')
|
||||
global_action.append_item('set-backoffice-fields')
|
||||
global_action.add_action('set-backoffice-fields')
|
||||
setbo = global_action.items[0]
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': '{{ caller_form_var_email }}'}]
|
||||
trigger = global_action.append_trigger('webservice')
|
||||
|
@ -6476,7 +6381,7 @@ def test_call_external_workflow_use_caller_variable(pub):
|
|||
wf.add_status('Action')
|
||||
|
||||
update_global_action = wf.add_global_action('Update linked object data')
|
||||
update_action = update_global_action.append_item('external_workflow_global_action')
|
||||
update_action = update_global_action.add_action('external_workflow_global_action')
|
||||
update_action.slug = 'carddef:%s' % carddef.url_name
|
||||
update_action.trigger_id = 'action:update'
|
||||
wf.store()
|
||||
|
@ -6529,7 +6434,7 @@ def test_call_external_workflow_manual_targeting(two_pubs):
|
|||
StringField(id='bo0', varname='bo', type='string', label='bo variable'),
|
||||
]
|
||||
global_action = carddef_wf.add_global_action('Update')
|
||||
global_action.append_item('set-backoffice-fields')
|
||||
global_action.add_action('set-backoffice-fields')
|
||||
setbo = global_action.items[0]
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': '{{ form_var_bo|default:"0"|add:1 }}'}]
|
||||
trigger = global_action.append_trigger('webservice')
|
||||
|
@ -6557,21 +6462,18 @@ def test_call_external_workflow_manual_targeting(two_pubs):
|
|||
st1 = wf.add_status('Action')
|
||||
|
||||
update_global_action = wf.add_global_action('Update linked object data')
|
||||
update_action = update_global_action.append_item('external_workflow_global_action')
|
||||
update_action = update_global_action.add_action('external_workflow_global_action')
|
||||
update_action.slug = 'carddef:%s' % carddef.url_name
|
||||
update_action.target_mode = 'manual'
|
||||
update_action.target_id = None # not configured
|
||||
update_action.trigger_id = 'action:update'
|
||||
|
||||
# and create carddata
|
||||
create_carddata = CreateCarddataWorkflowStatusItem()
|
||||
create_carddata = st1.add_action('create_carddata', id='_create_card')
|
||||
create_carddata.label = 'create linked card'
|
||||
create_carddata.formdef_slug = carddef.url_name
|
||||
create_carddata.varname = 'created_card'
|
||||
create_carddata.id = '_create_card'
|
||||
create_carddata.mappings = [Mapping(field_id='0', expression='{{ form_var_string }}')]
|
||||
create_carddata.parent = st1
|
||||
st1.items.append(create_carddata)
|
||||
|
||||
wf.store()
|
||||
|
||||
|
@ -6716,7 +6618,7 @@ def test_call_external_workflow_manual_queryset_targeting(two_pubs):
|
|||
StringField(id='bo0', varname='bo', type='string', label='bo variable'),
|
||||
]
|
||||
global_action = carddef_wf.add_global_action('Update')
|
||||
global_action.append_item('set-backoffice-fields')
|
||||
global_action.add_action('set-backoffice-fields')
|
||||
setbo = global_action.items[0]
|
||||
setbo.fields = [{'field_id': 'bo0', 'value': '{{ form_var_bo|default:"0"|add:1 }}'}]
|
||||
trigger = global_action.append_trigger('webservice') # external call
|
||||
|
@ -6745,7 +6647,7 @@ def test_call_external_workflow_manual_queryset_targeting(two_pubs):
|
|||
wf = Workflow(name='External actions')
|
||||
wf.add_status('Blah')
|
||||
update_global_action = wf.add_global_action('Update linked object data')
|
||||
update_action = update_global_action.append_item('external_workflow_global_action')
|
||||
update_action = update_global_action.add_action('external_workflow_global_action')
|
||||
update_action.slug = 'carddef:%s' % carddef.url_name
|
||||
update_action.target_mode = 'manual'
|
||||
update_action.target_id = None # not configured
|
||||
|
@ -6842,13 +6744,13 @@ def test_conditional_jump_vs_tracing(pub):
|
|||
workflow = Workflow(name='wf')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
comment = st1.append_item('register-comment')
|
||||
comment = st1.add_action('register-comment')
|
||||
comment.comment = 'hello world'
|
||||
jump1 = st1.append_item('jump')
|
||||
jump1 = st1.add_action('jump')
|
||||
jump1.parent = st1
|
||||
jump1.condition = {'type': 'django', 'value': 'False'}
|
||||
jump1.status = 'wf-st2'
|
||||
jump2 = st1.append_item('jump')
|
||||
jump2 = st1.add_action('jump')
|
||||
jump2.parent = st1
|
||||
jump2.status = 'wf-st2'
|
||||
workflow.store()
|
||||
|
|
|
@ -10,11 +10,7 @@ from wcs.fields import DateField, FileField, ItemField, MapField, StringField
|
|||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.assign_carddata import AssignCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.edit_carddata import EditCarddataWorkflowStatusItem
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
@ -77,10 +73,9 @@ def test_create_carddata(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-carddata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_carddata', id='_create', prepend=True)
|
||||
create.label = 'Create CardDef'
|
||||
create.varname = 'mycard'
|
||||
create.id = '_create'
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='1', expression='=form_var_undefined'),
|
||||
|
@ -88,8 +83,6 @@ def test_create_carddata(two_pubs):
|
|||
Mapping(field_id='3', expression='{{ form_var_date }}'),
|
||||
Mapping(field_id='4', expression='{{ form_var_file|default_if_none:"" }}'),
|
||||
]
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -173,27 +166,21 @@ def test_create_carddata_with_links(pub):
|
|||
|
||||
wf = Workflow(name='create-carddata')
|
||||
st1 = wf.add_status('Create cards', 'st1')
|
||||
create1 = CreateCarddataWorkflowStatusItem()
|
||||
create1 = st1.add_action('create_carddata', id='_create1')
|
||||
create1.label = 'Create CardDef1'
|
||||
create1.varname = 'mycard1'
|
||||
create1.id = '_create1'
|
||||
create1.formdef_slug = carddef1.url_name
|
||||
create1.mappings = [
|
||||
Mapping(field_id='1', expression='{{ form_var_card1_foo }}'),
|
||||
]
|
||||
create1.parent = st1
|
||||
st1.items.append(create1)
|
||||
create2 = CreateCarddataWorkflowStatusItem()
|
||||
create2 = st1.add_action('create_carddata', id='_create2')
|
||||
create2.label = 'Create CardDef2'
|
||||
create2.varname = 'mycard2'
|
||||
create2.id = '_create2'
|
||||
create2.formdef_slug = carddef2.url_name
|
||||
create2.mappings = [
|
||||
Mapping(field_id='1', expression='{{ form_var_card2_bar }}'),
|
||||
Mapping(field_id='2', expression='{{ form_links_mycard1 }}'),
|
||||
]
|
||||
create2.parent = st1
|
||||
st1.items.append(create2)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -348,16 +335,13 @@ def test_create_carddata_with_map_field(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-carddata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_carddata', id='_create', prepend=True)
|
||||
create.label = 'Create CardDef'
|
||||
create.varname = 'mycard'
|
||||
create.id = '_create'
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='1', expression=''),
|
||||
]
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -444,14 +428,11 @@ def test_create_carddata_user_association(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-carddata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_carddata', id='_create', prepend=True)
|
||||
create.label = 'Create CardDef'
|
||||
create.varname = 'mycard'
|
||||
create.id = '_create'
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.map_fields_by_varname = True
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -583,14 +564,11 @@ def test_create_carddata_map_fields_by_varname(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-carddata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_carddata', id='_create', prepend=True)
|
||||
create.label = 'Create CardDef'
|
||||
create.varname = 'mycard'
|
||||
create.id = '_create'
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.map_fields_by_varname = True
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -650,14 +628,11 @@ def test_edit_carddata_with_data_sourced_object(pub):
|
|||
wf = Workflow(name='Card update')
|
||||
st1 = wf.add_status('Update card', 'st1')
|
||||
|
||||
edit = EditCarddataWorkflowStatusItem()
|
||||
edit = st1.add_action('edit_carddata', id='edit')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.mappings = [
|
||||
Mapping(field_id='2', expression='{{ form_var_new_profession }}'),
|
||||
]
|
||||
edit.id = 'edit'
|
||||
st1.items.append(edit)
|
||||
edit.parent = st1
|
||||
wf.store()
|
||||
|
||||
datasource = {'type': 'carddef:%s' % carddef.url_name}
|
||||
|
@ -731,31 +706,23 @@ def test_edit_carddata_with_linked_object(pub):
|
|||
|
||||
wf = Workflow(name='Card create and update')
|
||||
st1 = wf.add_status('Create card', 'st1')
|
||||
edit = CreateCarddataWorkflowStatusItem()
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.mappings = [
|
||||
create = st1.add_action('create_carddata')
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='{{ form_var_first_name }}'),
|
||||
Mapping(field_id='1', expression='{{ form_var_last_name }}'),
|
||||
Mapping(field_id='2', expression='{{ form_var_kids_number|default:"0" }}'),
|
||||
]
|
||||
st1.items.append(edit)
|
||||
edit.parent = st1
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
st2 = wf.add_status('Update card', 'st2')
|
||||
edit = EditCarddataWorkflowStatusItem()
|
||||
edit = st2.add_action('edit_carddata', id='edit')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.mappings = [
|
||||
Mapping(field_id='2', expression='{{ form_var_kids_number|add:"1" }}'),
|
||||
]
|
||||
edit.id = 'edit'
|
||||
st2.items.append(edit)
|
||||
edit.parent = st2
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -812,32 +779,24 @@ def test_edit_carddata_manual_targeting(two_pubs):
|
|||
wf = Workflow(name='Card create and update')
|
||||
st1 = wf.add_status('Create card', 'st1')
|
||||
# create linked carddata
|
||||
edit = CreateCarddataWorkflowStatusItem()
|
||||
edit = st1.add_action('create_carddata')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.mappings = [
|
||||
Mapping(field_id='0', expression='{{ form_var_first_name }}'),
|
||||
Mapping(field_id='1', expression='{{ form_var_last_name }}'),
|
||||
Mapping(field_id='2', expression='{{ form_var_kids_number|default:"0" }}'),
|
||||
]
|
||||
st1.items.append(edit)
|
||||
edit.parent = st1
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
st2 = wf.add_status('Update card', 'st2')
|
||||
edit = EditCarddataWorkflowStatusItem()
|
||||
edit = st2.add_action('edit_carddata', id='edit')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.target_mode = 'manual' # not configured
|
||||
edit.mappings = [
|
||||
Mapping(field_id='2', expression='{{ form_var_kids_number|add:"1" }}'),
|
||||
]
|
||||
edit.id = 'edit'
|
||||
st2.items.append(edit)
|
||||
edit.parent = st2
|
||||
wf.store()
|
||||
|
||||
# associated formdef
|
||||
|
@ -987,22 +946,16 @@ def test_edit_carddata_targeting_itself(pub):
|
|||
st1 = card_wf.add_status('Status1')
|
||||
st2 = card_wf.add_status('Status2')
|
||||
|
||||
edit = EditCarddataWorkflowStatusItem()
|
||||
edit.id = '_edit'
|
||||
edit = st1.add_action('edit_carddata', id='_edit')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.target_mode = 'manual'
|
||||
edit.target_id = '{{ form_internal_id }}' # itself
|
||||
edit.mappings = [
|
||||
Mapping(field_id='0', expression='bar {{ form_internal_id }}'),
|
||||
]
|
||||
edit.parent = st1
|
||||
st1.items.append(edit)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', '_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
card_wf.store()
|
||||
|
||||
|
@ -1046,32 +999,23 @@ def test_edit_carddata_from_created_object(pub):
|
|||
st1 = card_wf.add_status('Status1')
|
||||
st2 = card_wf.add_status('Status2')
|
||||
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create.id = '_create'
|
||||
create = st1.add_action('create_formdata', id='_create')
|
||||
create.formdef_slug = formdef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='...'),
|
||||
]
|
||||
create.parent = st1
|
||||
st1.items.append(create)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
# form workflow: edit parent card data
|
||||
form_wf = Workflow(name='Form workflow')
|
||||
st1 = form_wf.add_status('Status1')
|
||||
edit = EditCarddataWorkflowStatusItem()
|
||||
edit = st1.add_action('edit_carddata', id='edit')
|
||||
edit.formdef_slug = carddef.url_name
|
||||
edit.mappings = [
|
||||
Mapping(field_id='0', expression='HELLO'),
|
||||
]
|
||||
edit.id = 'edit'
|
||||
st1.items.append(edit)
|
||||
edit.parent = st1
|
||||
form_wf.store()
|
||||
|
||||
carddef.workflow = card_wf
|
||||
|
@ -1118,12 +1062,9 @@ def test_assign_carddata_with_data_sourced_object(pub):
|
|||
wf = Workflow(name='Card update')
|
||||
st1 = wf.add_status('Assign card', 'st1')
|
||||
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign = st1.add_action('assign_carddata', id='assign')
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.user_association_mode = 'keep-user'
|
||||
assign.id = 'assign'
|
||||
st1.items.append(assign)
|
||||
assign.parent = st1
|
||||
wf.store()
|
||||
|
||||
datasource = {'type': 'carddef:%s' % carddef.url_name}
|
||||
|
@ -1167,29 +1108,21 @@ def test_assign_carddata_with_linked_object(pub):
|
|||
|
||||
wf = Workflow(name='Card create and assign')
|
||||
st1 = wf.add_status('Create card', 'st1')
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = st1.add_action('create_carddata')
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.user_association_mode = None
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='{{ form_var_first_name }}'),
|
||||
Mapping(field_id='1', expression='{{ form_var_last_name }}'),
|
||||
]
|
||||
st1.items.append(create)
|
||||
create.parent = st1
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
st2 = wf.add_status('Assign card', 'st2')
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign = st2.add_action('assign_carddata', id='assign')
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.user_association_mode = 'keep-user'
|
||||
assign.id = 'assign'
|
||||
st2.items.append(assign)
|
||||
assign.parent = st2
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -1250,30 +1183,22 @@ def test_assign_carddata_manual_targeting(two_pubs):
|
|||
wf = Workflow(name='Card create and Assign')
|
||||
st1 = wf.add_status('Create card', 'st1')
|
||||
# create linked carddata
|
||||
create = CreateCarddataWorkflowStatusItem()
|
||||
create = st1.add_action('create_carddata')
|
||||
create.formdef_slug = carddef.url_name
|
||||
create.user_association_mode = None
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='{{ form_var_first_name }}'),
|
||||
Mapping(field_id='1', expression='{{ form_var_last_name }}'),
|
||||
]
|
||||
st1.items.append(create)
|
||||
create.parent = st1
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.by = ['_submitter', '_receiver']
|
||||
jump.status = 'st2'
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
st2 = wf.add_status('Assign card', 'st2')
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign = st2.add_action('assign_carddata', id='assign')
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.target_mode = 'manual' # not configured
|
||||
assign.user_association_mode = 'keep-user'
|
||||
assign.id = 'assign'
|
||||
st2.items.append(assign)
|
||||
assign.parent = st2
|
||||
wf.store()
|
||||
|
||||
# associated formdef
|
||||
|
@ -1429,21 +1354,15 @@ def test_assign_carddata_targeting_itself(pub):
|
|||
st1 = card_wf.add_status('Status1')
|
||||
st2 = card_wf.add_status('Status2')
|
||||
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign.id = '_assign'
|
||||
assign = st1.add_action('assign_carddata', id='_assign')
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.target_mode = 'manual'
|
||||
assign.target_id = '{{ form_internal_id }}' # itself
|
||||
assign.user_association_mode = 'custom'
|
||||
assign.user_association_template = 'xyz'
|
||||
assign.parent = st1
|
||||
st1.items.append(assign)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
card_wf.store()
|
||||
|
||||
|
@ -1495,31 +1414,22 @@ def test_assign_carddata_from_created_object(pub):
|
|||
st1 = card_wf.add_status('Status1')
|
||||
st2 = card_wf.add_status('Status2')
|
||||
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create.id = '_create'
|
||||
create = st1.add_action('create_formdata', id='_create')
|
||||
create.formdef_slug = formdef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='...'),
|
||||
]
|
||||
create.parent = st1
|
||||
st1.items.append(create)
|
||||
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.id = '_jump'
|
||||
jump = st1.add_action('jump', id='_jump')
|
||||
jump.status = st2.id
|
||||
st1.items.append(jump)
|
||||
jump.parent = st1
|
||||
|
||||
# form workflow: assign parent card data
|
||||
form_wf = Workflow(name='Form workflow')
|
||||
st1 = form_wf.add_status('Status1')
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign = st1.add_action('assign_carddata', id='assign')
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.user_association_mode = 'custom'
|
||||
assign.user_association_template = 'xyz'
|
||||
assign.id = 'assign'
|
||||
st1.items.append(assign)
|
||||
assign.parent = st1
|
||||
form_wf.store()
|
||||
|
||||
carddef.workflow = card_wf
|
||||
|
@ -1570,13 +1480,10 @@ def test_assign_carddata_user_association(two_pubs):
|
|||
|
||||
wf = Workflow(name='assign-carddata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
assign = AssignCarddataWorkflowStatusItem()
|
||||
assign = wf.possible_status[1].add_action('assign_carddata', id='_assign', prepend=True)
|
||||
assign.label = 'Assign CardDef'
|
||||
assign.varname = 'mycard'
|
||||
assign.id = '_assign'
|
||||
assign.formdef_slug = carddef.url_name
|
||||
assign.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, assign)
|
||||
wf.store()
|
||||
|
||||
datasource = {'type': 'carddef:%s' % carddef.url_name}
|
||||
|
|
|
@ -13,7 +13,6 @@ from wcs.qommon.http_request import HTTPRequest
|
|||
from wcs.qommon.substitution import CompatibilityNamesDict
|
||||
from wcs.qommon.upload_storage import PicklableUpload
|
||||
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
|
||||
from wcs.wf.dispatch import DispatchWorkflowStatusItem
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
|
||||
|
||||
|
@ -493,17 +492,13 @@ def test_workflow_email_to_user_function(pub, emails):
|
|||
|
||||
workflow = Workflow(name='wf roles')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
item1 = DispatchWorkflowStatusItem()
|
||||
item1 = st1.add_action('dispatch')
|
||||
item1.role_key = '_receiver'
|
||||
item1.role_id = '{{ form_user }}'
|
||||
st1.items.append(item1)
|
||||
item1.parent = st1
|
||||
item2 = SendmailWorkflowStatusItem()
|
||||
item2 = st1.add_action('sendmail')
|
||||
item2.to = ['_receiver']
|
||||
item2.subject = 'Foobar'
|
||||
item2.body = 'Hello'
|
||||
st1.items.append(item2)
|
||||
item2.parent = st1
|
||||
workflow.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
|
|
@ -6,8 +6,7 @@ from wcs.carddef import CardDef
|
|||
from wcs.fields import EmailField, ItemField, StringField
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.http_request import HTTPRequest
|
||||
from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
|
||||
from wcs.wf.sendmail import SendmailWorkflowStatusItem
|
||||
from wcs.wf.create_formdata import Mapping
|
||||
from wcs.workflows import Workflow
|
||||
|
||||
from ..utilities import clean_temporary_pub, create_temporary_pub
|
||||
|
@ -67,17 +66,14 @@ def test_create_formdata(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-formdata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_formdata', id='_create', prepend=True)
|
||||
create.label = 'create a new linked form'
|
||||
create.varname = 'resubmitted'
|
||||
create.id = '_create'
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
Mapping(field_id='2', expression='=form_var_toto_item_raw'),
|
||||
]
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
source_formdef = FormDef()
|
||||
|
@ -156,8 +152,7 @@ def test_create_formdata_migration(pub):
|
|||
wf = Workflow(name='create-formdata')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create.id = '_create'
|
||||
create = st1.add_action('create_formdata', id='_create')
|
||||
create.label = 'create a new linked form'
|
||||
create.varname = 'resubmitted'
|
||||
create.mappings = [
|
||||
|
@ -165,9 +160,7 @@ def test_create_formdata_migration(pub):
|
|||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
Mapping(field_id='2', expression='=form_var_toto_item_raw'),
|
||||
]
|
||||
create.parent = st1
|
||||
create.keep_user = True
|
||||
st1.items.append(create)
|
||||
wf.store()
|
||||
|
||||
wf = Workflow.get(wf.id)
|
||||
|
@ -181,12 +174,10 @@ def test_create_formdata_tracking_code(two_pubs, emails):
|
|||
|
||||
target_wf = Workflow(name='send-mail')
|
||||
st1 = target_wf.add_status('Status1', 'st1')
|
||||
item = SendmailWorkflowStatusItem()
|
||||
item = st1.add_action('sendmail')
|
||||
item.to = ['bar@localhost']
|
||||
item.subject = 'Foobar'
|
||||
item.body = '{{ form_tracking_code }}'
|
||||
st1.items.append(item)
|
||||
item.parent = st1
|
||||
target_wf.store()
|
||||
|
||||
target_formdef = FormDef()
|
||||
|
@ -200,13 +191,11 @@ def test_create_formdata_tracking_code(two_pubs, emails):
|
|||
|
||||
wf = Workflow(name='create-formdata')
|
||||
st1 = wf.add_status('Status1', 'st1')
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create = st1.add_action('create_formdata')
|
||||
create.formdef_slug = target_formdef.url_name
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_email_string'),
|
||||
]
|
||||
st1.items.append(create)
|
||||
item.parent = st1
|
||||
wf.store()
|
||||
|
||||
formdef = FormDef()
|
||||
|
@ -246,17 +235,14 @@ def test_create_formdata_attach_to_history(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-formdata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_formdata', id='_create', prepend=True)
|
||||
create.label = 'create a new linked form'
|
||||
create.varname = 'resubmitted'
|
||||
create.id = '_create'
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='=form_var_toto_string'),
|
||||
Mapping(field_id='1', expression='=form_var_toto_file_raw'),
|
||||
Mapping(field_id='2', expression='=form_var_toto_item_raw'),
|
||||
]
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
source_formdef = FormDef()
|
||||
|
@ -323,15 +309,12 @@ def test_create_formdata_card_item_mapping(two_pubs):
|
|||
|
||||
wf = Workflow(name='create-formdata')
|
||||
wf.possible_status = Workflow.get_default_workflow().possible_status[:]
|
||||
create = CreateFormdataWorkflowStatusItem()
|
||||
create = wf.possible_status[1].add_action('create_formdata', id='_create', prepend=True)
|
||||
create.label = 'create a new linked form'
|
||||
create.id = '_create'
|
||||
create.formdef_slug = 'foo'
|
||||
create.mappings = [
|
||||
Mapping(field_id='0', expression='{{ form_var_foo_string|default:"" }}'),
|
||||
]
|
||||
create.parent = wf.possible_status[1]
|
||||
wf.possible_status[1].items.insert(0, create)
|
||||
wf.store()
|
||||
|
||||
source_formdef = FormDef()
|
||||
|
|
|
@ -488,7 +488,7 @@ class WorkflowItemPage(Directory):
|
|||
|
||||
item = self.item.export_to_xml('utf-8')
|
||||
item_type = item.attrib['type']
|
||||
new_item = destination_status.append_item(item_type)
|
||||
new_item = destination_status.add_action(item_type)
|
||||
new_item.parent = destination_status
|
||||
try:
|
||||
new_item.init_with_xml(item, 'utf-8', check_datasources=False)
|
||||
|
@ -717,7 +717,7 @@ class WorkflowStatusPage(Directory):
|
|||
for category in ('status-change', 'interaction', 'formdata-action', 'user-action'):
|
||||
action_type = form.get_widget('action-%s' % category).parse()
|
||||
if action_type:
|
||||
self.status.append_item(action_type)
|
||||
self.status.add_action(action_type)
|
||||
self.workflow.store(
|
||||
comment=_('New action "%(description)s" in status "%(status)s"')
|
||||
% {
|
||||
|
|
|
@ -103,18 +103,18 @@ class CardDef(FormDef):
|
|||
status = workflow.add_status(force_text(_('Recorded')), 'recorded')
|
||||
deleted_status = workflow.add_status(force_text(_('Deleted')), 'deleted')
|
||||
|
||||
editable = status.append_item('editable', id='_editable')
|
||||
editable = status.add_action('editable', id='_editable')
|
||||
editable.by = ['_editor']
|
||||
editable.label = force_text(_('Edit Card'))
|
||||
editable.status = status.id
|
||||
|
||||
action_delete = status.append_item('choice', id='_action_delete')
|
||||
action_delete = status.add_action('choice', id='_action_delete')
|
||||
action_delete.by = ['_editor']
|
||||
action_delete.label = force_text(_('Delete Card'))
|
||||
action_delete.status = deleted_status.id
|
||||
action_delete.require_confirmation = True
|
||||
|
||||
deleted_status.append_item('remove', id='_remove')
|
||||
deleted_status.add_action('remove', id='_remove')
|
||||
|
||||
return workflow
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import base64
|
||||
import collections
|
||||
import copy
|
||||
import datetime
|
||||
import glob
|
||||
import itertools
|
||||
|
@ -1034,7 +1033,7 @@ class Workflow(StorableObject):
|
|||
finished_status.colour = 'CCCCCC'
|
||||
|
||||
if EmailsDirectory.is_enabled('new_receiver'):
|
||||
notify_new_receiver_email = just_submitted_status.append_item(
|
||||
notify_new_receiver_email = just_submitted_status.add_action(
|
||||
'sendmail', id='_notify_new_receiver_email'
|
||||
)
|
||||
notify_new_receiver_email.to = ['_receiver']
|
||||
|
@ -1042,17 +1041,17 @@ class Workflow(StorableObject):
|
|||
notify_new_receiver_email.body = EmailsDirectory.get_body('new_receiver')
|
||||
|
||||
if EmailsDirectory.is_enabled('new_user'):
|
||||
notify_new_user_email = just_submitted_status.append_item('sendmail', id='_notify_new_user_email')
|
||||
notify_new_user_email = just_submitted_status.add_action('sendmail', id='_notify_new_user_email')
|
||||
notify_new_user_email.to = ['_submitter']
|
||||
notify_new_user_email.subject = EmailsDirectory.get_subject('new_user')
|
||||
notify_new_user_email.body = EmailsDirectory.get_body('new_user')
|
||||
|
||||
jump_to_new = just_submitted_status.append_item('jump', id='_jump_to_new')
|
||||
jump_to_new = just_submitted_status.add_action('jump', id='_jump_to_new')
|
||||
jump_to_new.status = new_status.id
|
||||
|
||||
if EmailsDirectory.is_enabled('change_receiver'):
|
||||
for status in (accepted_status, rejected_status, finished_status):
|
||||
notify_change_receiver_email = status.append_item(
|
||||
notify_change_receiver_email = status.add_action(
|
||||
'sendmail', id='_notify_change_receiver_email'
|
||||
)
|
||||
notify_change_receiver_email.to = ['_receiver']
|
||||
|
@ -1061,26 +1060,26 @@ class Workflow(StorableObject):
|
|||
|
||||
if EmailsDirectory.is_enabled('change_user'):
|
||||
for status in (accepted_status, rejected_status, finished_status):
|
||||
notify_change_user_email = status.append_item('sendmail', id='_notify_change_user_email')
|
||||
notify_change_user_email = status.add_action('sendmail', id='_notify_change_user_email')
|
||||
notify_change_user_email.to = ['_submitter']
|
||||
notify_change_user_email.subject = EmailsDirectory.get_subject('change_user')
|
||||
notify_change_user_email.body = EmailsDirectory.get_body('change_user')
|
||||
|
||||
for status in (new_status, accepted_status):
|
||||
commentable = status.append_item('commentable', id='_commentable')
|
||||
commentable = status.add_action('commentable', id='_commentable')
|
||||
commentable.by = ['_submitter', '_receiver']
|
||||
|
||||
accept = new_status.append_item('choice', id='_accept')
|
||||
accept = new_status.add_action('choice', id='_accept')
|
||||
accept.label = force_text(_('Accept'))
|
||||
accept.by = ['_receiver']
|
||||
accept.status = accepted_status.id
|
||||
|
||||
reject = new_status.append_item('choice', id='_reject')
|
||||
reject = new_status.add_action('choice', id='_reject')
|
||||
reject.label = force_text(_('Reject'))
|
||||
reject.by = ['_receiver']
|
||||
reject.status = rejected_status.id
|
||||
|
||||
finish = accepted_status.append_item('choice', id='_finish')
|
||||
finish = accepted_status.add_action('choice', id='_finish')
|
||||
finish.label = force_text(_('Finish'))
|
||||
finish.by = ['_receiver']
|
||||
finish.status = finished_status.id
|
||||
|
@ -1677,7 +1676,9 @@ class WorkflowGlobalActionWebserviceTrigger(WorkflowGlobalActionManualTrigger):
|
|||
class SerieOfActionsMixin:
|
||||
items = None
|
||||
|
||||
def append_item(self, type, id=None):
|
||||
def add_action(self, type, id=None, prepend=False):
|
||||
if not self.items:
|
||||
self.items = []
|
||||
for klass in item_classes:
|
||||
if klass.key == type:
|
||||
o = klass()
|
||||
|
@ -1688,15 +1689,18 @@ class SerieOfActionsMixin:
|
|||
else:
|
||||
o.id = '1'
|
||||
o.parent = self
|
||||
self.items.append(o)
|
||||
if prepend:
|
||||
self.items.insert(0, o)
|
||||
else:
|
||||
self.items.append(o)
|
||||
return o
|
||||
raise KeyError()
|
||||
raise KeyError(type)
|
||||
|
||||
def get_item(self, id):
|
||||
for item in self.items:
|
||||
if item.id == id:
|
||||
return item
|
||||
raise KeyError()
|
||||
raise KeyError(id)
|
||||
|
||||
def get_dependencies(self):
|
||||
for action in self.items or []:
|
||||
|
@ -1764,7 +1768,7 @@ class WorkflowGlobalAction(SerieOfActionsMixin):
|
|||
self.items = []
|
||||
for item in elem.find('items'):
|
||||
item_type = item.attrib['type']
|
||||
self.append_item(item_type)
|
||||
self.add_action(item_type)
|
||||
item_o = self.items[-1]
|
||||
item_o.parent = self
|
||||
item_o.init_with_xml(item, charset, include_id=include_id, snapshot=snapshot)
|
||||
|
@ -2080,7 +2084,7 @@ class WorkflowStatus(SerieOfActionsMixin):
|
|||
unknown_referenced_objects_details = collections.defaultdict(set)
|
||||
for item in elem.find('items'):
|
||||
item_type = item.attrib['type']
|
||||
self.append_item(item_type)
|
||||
self.add_action(item_type)
|
||||
item_o = self.items[-1]
|
||||
item_o.parent = self
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue