workflows: sort workflow actions in categories (#3405)
This commit is contained in:
parent
5cc3847843
commit
4ed32befc2
|
@ -1681,14 +1681,14 @@ def test_workflows_new(pub):
|
|||
|
||||
# create a new action
|
||||
resp = resp.click('new status')
|
||||
resp.forms[0]['type'] = 'Display message'
|
||||
resp.forms[0]['action-interaction'] = 'Top Alert'
|
||||
resp = resp.forms[0].submit()
|
||||
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/'
|
||||
resp = resp.follow()
|
||||
assert 'Use drag and drop' in resp.body
|
||||
|
||||
# fill action
|
||||
resp = resp.click('Display message')
|
||||
resp = resp.click('Top Alert')
|
||||
resp.forms[0]['message'] = 'bla bla bla'
|
||||
resp = resp.forms[0].submit('submit')
|
||||
assert resp.location == 'http://example.net/backoffice/workflows/1/status/1/items/'
|
||||
|
@ -1953,16 +1953,20 @@ def test_workflows_add_all_actions(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
for action in [x[0] for x in resp.forms[0]['type'].options]:
|
||||
resp.forms[0]['type'] = action
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
for category in ('status-change', 'interaction', 'formdata-action', 'user-action'):
|
||||
for action in [x[0] for x in resp.forms[0]['action-%s' % category].options if x[0]]:
|
||||
resp.forms[0]['action-%s' % category] = action
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
for i in range(len(resp.forms[0]['type'].options)):
|
||||
resp = resp.click('Edit', href='items/%d/' % (i+1), index=0)
|
||||
resp = resp.forms[0].submit('cancel')
|
||||
resp = resp.follow() # redirect to items/
|
||||
resp = resp.follow() # redirect to ./
|
||||
i = 1
|
||||
for category in ('status-change', 'interaction', 'formdata-action', 'user-action'):
|
||||
for action in [x[0] for x in resp.forms[0]['action-%s' % category].options if x[0]]:
|
||||
resp = resp.click('Edit', href='items/%d/' % i, index=0)
|
||||
resp = resp.forms[0].submit('cancel')
|
||||
resp = resp.follow() # redirect to items/
|
||||
resp = resp.follow() # redirect to ./
|
||||
i += 1
|
||||
|
||||
def test_workflows_check_available_actions(pub):
|
||||
create_superuser(pub)
|
||||
|
@ -1976,8 +1980,8 @@ def test_workflows_check_available_actions(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
assert not 'Modify Criticality' in [x[0] for x in resp.forms[0]['type'].options]
|
||||
assert not 'Send SMS' in [x[0] for x in resp.forms[0]['type'].options]
|
||||
assert not 'Criticality Levels' in [x[0] for x in resp.forms[0]['action-formdata-action'].options]
|
||||
assert not 'SMS' in [x[0] for x in resp.forms[0]['action-interaction'].options]
|
||||
|
||||
pub.cfg['sms'] = {'mode': 'foobar'}
|
||||
pub.write_cfg()
|
||||
|
@ -1985,8 +1989,8 @@ def test_workflows_check_available_actions(pub):
|
|||
workflow.store()
|
||||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
assert 'Modify Criticality' in [x[0] for x in resp.forms[0]['type'].options]
|
||||
assert 'Send SMS' in [x[0] for x in resp.forms[0]['type'].options]
|
||||
assert 'Criticality Levels' in [x[0] for x in resp.forms[0]['action-formdata-action'].options]
|
||||
assert 'SMS' in [x[0] for x in resp.forms[0]['action-interaction'].options]
|
||||
|
||||
def test_workflows_edit_dispatch_action(pub):
|
||||
create_superuser(pub)
|
||||
|
@ -2000,18 +2004,18 @@ def test_workflows_edit_dispatch_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.forms[0]['type'] = 'Assign a Function'
|
||||
resp.forms[0]['action-formdata-action'] = 'Function/Role Linking'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
resp = resp.click('Assign a Function')
|
||||
resp = resp.click('Function/Role Linking')
|
||||
resp.form['rules$element0$value'].value = 'FOOBAR'
|
||||
resp.form['rules$element0$role_id'].value = str(role.id)
|
||||
resp = resp.form.submit('submit')
|
||||
resp = resp.follow()
|
||||
resp = resp.follow()
|
||||
|
||||
resp = resp.click('Assign a Function')
|
||||
resp = resp.click('Function/Role Linking')
|
||||
assert resp.form['rules$element0$value'].value == 'FOOBAR'
|
||||
resp.form['rules$element1$value'].value = 'BARFOO'
|
||||
resp.form['rules$element1$role_id'].value = str(role.id)
|
||||
|
@ -2033,11 +2037,11 @@ def test_workflows_edit_email_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.forms[0]['type'] = 'Send mail'
|
||||
resp.forms[0]['action-interaction'] = 'Email'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
resp = resp.click('Send mail')
|
||||
resp = resp.click('Email')
|
||||
item_url = resp.request.url
|
||||
|
||||
ok_strings = [
|
||||
|
@ -2211,10 +2215,10 @@ def test_workflows_edit_sms_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.form['type'] = 'Send SMS'
|
||||
resp.form['action-interaction'] = 'SMS'
|
||||
resp = resp.form.submit().follow()
|
||||
|
||||
resp = resp.click('Send SMS')
|
||||
resp = resp.click('SMS')
|
||||
resp = resp.form.submit()
|
||||
|
||||
def test_workflows_edit_display_form_action(pub):
|
||||
|
@ -2229,11 +2233,11 @@ def test_workflows_edit_display_form_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.forms[0]['type'] = 'Display a form'
|
||||
resp.forms[0]['action-interaction'] = 'Form'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
resp = resp.click('Display a form')
|
||||
resp = resp.click(re.compile('^Form$'))
|
||||
resp = resp.click('Edit Fields')
|
||||
|
||||
resp.form['label'] = 'foobar'
|
||||
|
@ -2257,7 +2261,7 @@ def test_workflows_edit_choice_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.forms[0]['type'] = 'Change Status'
|
||||
resp.forms[0]['action-status-change'] = 'Manual Jump'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
|
@ -2349,10 +2353,10 @@ def test_workflows_delete_action(pub):
|
|||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
|
||||
resp.forms[0]['type'] = 'Send mail'
|
||||
resp.forms[0]['action-interaction'] = 'Email'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
assert 'Send mail' in resp.body
|
||||
assert 'Email' in resp.body
|
||||
|
||||
resp = resp.click(href='items/1/delete')
|
||||
resp = resp.form.submit('cancel')
|
||||
|
@ -2493,7 +2497,7 @@ def test_workflows_backoffice_fields(pub):
|
|||
# check the "set backoffice fields" action is now available
|
||||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz')
|
||||
resp.forms[0]['type'] = 'Set Backoffice Fields'
|
||||
resp.forms[0]['action-formdata-action'] = 'Backoffice Data'
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
|
@ -2528,7 +2532,7 @@ def test_workflows_backoffice_fields(pub):
|
|||
# check backoffice fields are available in set backoffice fields action
|
||||
resp = app.get('/backoffice/workflows/1/')
|
||||
resp = resp.click('baz') # status
|
||||
resp = resp.click('Set Backoffice Fields')
|
||||
resp = resp.click('Backoffice Data')
|
||||
options = [x[2] for x in resp.form['fields$element0$field_id'].options]
|
||||
assert '' in options
|
||||
assert 'foobar' in options
|
||||
|
@ -2680,10 +2684,11 @@ def test_workflows_global_actions_edit(pub):
|
|||
resp = resp.follow()
|
||||
|
||||
# test adding all actions
|
||||
for action in [x[0] for x in resp.forms[0]['type'].options]:
|
||||
resp.forms[0]['type'] = action
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
for category in ('status-change', 'interaction', 'formdata-action', 'user-action'):
|
||||
for action in [x[0] for x in resp.forms[0]['action-%s' % category].options if x[0]]:
|
||||
resp.forms[0]['action-%s' % category] = action
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
# test visiting
|
||||
action_id = Workflow.get(workflow.id).global_actions[0].id
|
||||
|
@ -2833,13 +2838,13 @@ def test_workflows_wscall_label(pub):
|
|||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/workflows/%s/status/%s/' % (workflow.id, baz_status.id))
|
||||
assert 'Webservice Call' in resp.body
|
||||
assert 'Webservice Call "' not in resp.body
|
||||
assert 'Webservice' in resp.body
|
||||
assert 'Webservice (' not in resp.body
|
||||
|
||||
wscall.label = 'foowscallbar'
|
||||
workflow.store()
|
||||
resp = app.get('/backoffice/workflows/%s/status/%s/' % (workflow.id, baz_status.id))
|
||||
assert 'Webservice Call "foowscallbar"' in resp.body
|
||||
assert 'Webservice (foowscallbar)' in resp.body
|
||||
|
||||
def test_workflows_inspect_view(pub):
|
||||
from wcs.workflows import WorkflowVariablesFieldsFormDef
|
||||
|
|
|
@ -3034,14 +3034,14 @@ def test_redirect_to_url(pub):
|
|||
formdata.data = {'1': 'bar'}
|
||||
|
||||
item = RedirectToUrlWorkflowStatusItem()
|
||||
assert item.render_as_line() == 'Redirect to URL (not configured)'
|
||||
assert item.render_as_line() == 'Web Redirection (not configured)'
|
||||
item.url = 'https://www.example.net/?foo=[form_var_foo]'
|
||||
assert item.render_as_line() == 'Redirect to URL "https://www.example.net/?foo=[form_var_foo]"'
|
||||
assert item.render_as_line() == 'Web Redirection (to https://www.example.net/?foo=[form_var_foo])'
|
||||
pub.substitutions.feed(formdata)
|
||||
assert item.perform(formdata) == 'https://www.example.net/?foo=bar'
|
||||
|
||||
item.url = 'https://www.example.net/?django={{ form_var_foo }}'
|
||||
assert item.render_as_line() == 'Redirect to URL "https://www.example.net/?django={{ form_var_foo }}"'
|
||||
assert item.render_as_line() == 'Web Redirection (to https://www.example.net/?django={{ form_var_foo }})'
|
||||
pub.substitutions.feed(formdata)
|
||||
assert item.perform(formdata) == 'https://www.example.net/?django=bar'
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ class WorkflowStatusPage(Directory):
|
|||
r += htmltext('<li><a href="delete" rel="popup">%s</a></li>') % _('Delete')
|
||||
r += htmltext('</ul>')
|
||||
r += htmltext('<div id="new-field">')
|
||||
r += htmltext('<h3>%s</h3>') % _('New Item')
|
||||
r += htmltext('<h3>%s</h3>') % _('New Action')
|
||||
r += self.get_new_item_form().render()
|
||||
r += htmltext('</div>')
|
||||
return r.getvalue()
|
||||
|
@ -505,18 +505,22 @@ class WorkflowStatusPage(Directory):
|
|||
return item.is_available(workflow=self.workflow)
|
||||
|
||||
def get_new_item_form(self):
|
||||
form = Form(enctype='multipart/form-data', action = 'newitem')
|
||||
form = Form(enctype='multipart/form-data', action='newitem',
|
||||
id='new-action-form')
|
||||
categories = [
|
||||
('status-change', _('Change Status')),
|
||||
('interaction', _('Interact')),
|
||||
('formdata-action', _('Act on Form')),
|
||||
('user-action', _('Act on User')),
|
||||
]
|
||||
available_items = [x for x in item_classes if self.is_item_available(x)]
|
||||
def cmp_items(x, y):
|
||||
t = cmp(x.category and x.category[0], y.category and y.category[0])
|
||||
if t:
|
||||
return t
|
||||
return cmp(_(x.description), _(y.description))
|
||||
available_items.sort(key=lambda x: misc.simplify(_(x.description)))
|
||||
|
||||
available_items.sort(cmp_items)
|
||||
options = [(x.key, _(x.description)) for x in available_items]
|
||||
form.add(SingleSelectWidget, 'type', title = _('Type'),
|
||||
required=True, options = options)
|
||||
for category, category_label in categories:
|
||||
options = [(x.key, _(x.description)) for x in available_items
|
||||
if x.category == category]
|
||||
form.add(SingleSelectWidget, 'action-%s' % category, title=category_label,
|
||||
required=False, options=[(None, '')] + options)
|
||||
form.add_submit('submit', _('Add'))
|
||||
return form
|
||||
|
||||
|
@ -534,16 +538,17 @@ class WorkflowStatusPage(Directory):
|
|||
get_session().message = ('error', _('Submitted form was not filled properly.'))
|
||||
return redirect('.')
|
||||
|
||||
if form.get_widget('type').parse():
|
||||
self.status.append_item(form.get_widget('type').parse())
|
||||
else:
|
||||
get_session().message = ('error', _('Submitted form was not filled properly.'))
|
||||
return redirect('.')
|
||||
|
||||
self.workflow.store()
|
||||
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.workflow.store()
|
||||
return redirect('.')
|
||||
|
||||
get_session().message = ('error', _('Submitted form was not filled properly.'))
|
||||
return redirect('.')
|
||||
|
||||
|
||||
def delete(self):
|
||||
form = Form(enctype="multipart/form-data")
|
||||
form.widgets.append(HtmlWidget('<p>%s</p>' % _(
|
||||
|
|
|
@ -1626,6 +1626,10 @@ div.widget input[type=text][readonly] {
|
|||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
#new-action-form select[disabled] {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
table div.file-field img {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,17 @@ $(function() {
|
|||
$('input[type=hidden][name=submission_channel]').val($(this).val());
|
||||
});
|
||||
|
||||
/* new action form */
|
||||
$('#new-action-form select').on('change', function() {
|
||||
if ($(this).val() == '') {
|
||||
$('#new-action-form select').prop('disabled', null)
|
||||
} else {
|
||||
$('#new-action-form select').prop('disabled', 'disabled')
|
||||
$(this).prop('disabled', null)
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/* possibility to toggle the sidebar */
|
||||
if ($('#sidebar').length) {
|
||||
$('#main-content').after($('<span id="sidebar-toggle">⁞</span>'));
|
||||
|
|
|
@ -27,17 +27,18 @@ from wcs.workflows import WorkflowStatusItem, register_item_class, \
|
|||
from wcs.roles import Role
|
||||
|
||||
class AggregationEmailWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Aggregate to summary email')
|
||||
description = N_('Daily Summary Email')
|
||||
key = 'aggregationemail'
|
||||
category = 'interaction'
|
||||
ok_in_global_action = False
|
||||
|
||||
to = []
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.to:
|
||||
return _('Aggregate for summary email to %s') % self.render_list_of_roles(self.to)
|
||||
return _('to %s') % self.render_list_of_roles(self.to)
|
||||
else:
|
||||
return _('Aggregate for summary email (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None):
|
||||
if 'to' in parameters:
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
from wcs.workflows import WorkflowStatusItem, register_item_class
|
||||
|
||||
class AnonymiseWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Anonymise')
|
||||
description = N_('Anonymisation')
|
||||
key = 'anonymise'
|
||||
category = 'formdata-action'
|
||||
|
||||
def perform(self, formdata):
|
||||
formdata.anonymise()
|
||||
|
|
|
@ -66,8 +66,9 @@ def form_attachment(self):
|
|||
|
||||
|
||||
class AddAttachmentWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Allow Joining a File')
|
||||
description = N_('Attachment')
|
||||
key = 'addattachment'
|
||||
category = 'interaction'
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
ok_in_global_action = False
|
||||
|
@ -91,11 +92,11 @@ class AddAttachmentWorkflowStatusItem(WorkflowStatusItem):
|
|||
FileDirectory._lookup_methods.append('lookup_wf_attachment')
|
||||
FileDirectory.lookup_wf_attachment = lookup_wf_attachment
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.by:
|
||||
return _('Allow Joining a File, by %s') % self.render_list_of_roles(self.by)
|
||||
return _('by %s') % self.render_list_of_roles(self.by)
|
||||
else:
|
||||
return _('Allow Joining a File (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
if self.display_title:
|
||||
|
|
|
@ -65,8 +65,9 @@ class SetBackofficeFieldsTableWidget(WidgetListAsTable):
|
|||
|
||||
|
||||
class SetBackofficeFieldsWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Set Backoffice Fields')
|
||||
description = N_('Backoffice Data')
|
||||
key = 'set-backoffice-fields'
|
||||
category = 'formdata-action'
|
||||
|
||||
fields = None
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ MODE_DEC = '2'
|
|||
MODE_SET = '3'
|
||||
|
||||
class ModifyCriticalityWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Modify Criticality')
|
||||
description = N_('Criticality Levels')
|
||||
key = 'modify_criticality'
|
||||
category = 'formdata-action'
|
||||
|
||||
mode = MODE_INC
|
||||
absolute_value = None
|
||||
|
|
|
@ -78,8 +78,9 @@ class RuleNode(XmlSerialisable):
|
|||
|
||||
|
||||
class DispatchWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Assign a Function')
|
||||
description = N_('Function/Role Linking')
|
||||
key = 'dispatch'
|
||||
category = 'formdata-action'
|
||||
|
||||
role_id = None
|
||||
role_key = None
|
||||
|
@ -121,11 +122,11 @@ class DispatchWorkflowStatusItem(WorkflowStatusItem):
|
|||
if rules:
|
||||
self.rules = rules
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.role_key:
|
||||
function_label = self.parent.parent.roles.get(self.role_key, '?')
|
||||
return _('Assign a Function (%s)') % function_label
|
||||
return _('Assign a Function')
|
||||
return function_label
|
||||
return None
|
||||
|
||||
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None):
|
||||
if 'role_key' in parameters:
|
||||
|
|
|
@ -194,8 +194,9 @@ def rtf_process(value):
|
|||
|
||||
|
||||
class ExportToModel(WorkflowStatusItem):
|
||||
description = N_('Create Document')
|
||||
description = N_('Document Creation')
|
||||
key = 'export_to_model'
|
||||
category = 'formdata-action'
|
||||
support_substitution_variables = True
|
||||
ok_in_global_action = False
|
||||
|
||||
|
@ -214,14 +215,13 @@ class ExportToModel(WorkflowStatusItem):
|
|||
method = 'interactive'
|
||||
backoffice_filefield_id = None
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.model_file:
|
||||
model = _('with model named %(file_name)s of %(size)s bytes') % {
|
||||
return _('with model named %(file_name)s of %(size)s bytes') % {
|
||||
'file_name': self.model_file.base_filename,
|
||||
'size': self.model_file.size}
|
||||
else:
|
||||
model = _('no model set')
|
||||
return _('Create document %(model)s') % {'model': model}
|
||||
return _('no model set')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
if not self.method == 'interactive':
|
||||
|
|
|
@ -69,8 +69,9 @@ class WorkflowFormFieldsDirectory(FieldsDirectory):
|
|||
|
||||
|
||||
class FormWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Display a form')
|
||||
description = N_('Form')
|
||||
key = 'form'
|
||||
category = 'interaction'
|
||||
ok_in_global_action = False
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
|
|
|
@ -33,8 +33,9 @@ from qommon.misc import http_get_page, normalize_geolocation
|
|||
from wcs.workflows import WorkflowStatusItem, register_item_class
|
||||
|
||||
class GeolocateWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Geolocate')
|
||||
description = N_('Geolocation')
|
||||
key = 'geolocate'
|
||||
category = 'formdata-action'
|
||||
|
||||
method = 'address_string'
|
||||
address_string = None
|
||||
|
|
|
@ -95,7 +95,7 @@ class TriggerDirectory(Directory):
|
|||
|
||||
|
||||
class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
||||
description = N_('Change Status Automatically')
|
||||
description = N_('Automatic Jump')
|
||||
key = 'jump'
|
||||
|
||||
by = []
|
||||
|
@ -123,12 +123,12 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
return True
|
||||
return False
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if not self.status:
|
||||
return _('Change Status Automatically (not completed)')
|
||||
return _('not completed')
|
||||
wf_status = self.get_target_status()
|
||||
if not wf_status:
|
||||
return _('Change Status Automatically (broken)')
|
||||
return _('broken')
|
||||
reasons = []
|
||||
if self.condition:
|
||||
reasons.append(_('condition'))
|
||||
|
@ -138,11 +138,11 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
reasons.append(_('timeout'))
|
||||
|
||||
if reasons:
|
||||
return _('Change Status Automatically (to %(name)s) (%(reasons)s)') % {
|
||||
return _('to %(name)s, %(reasons)s') % {
|
||||
'name': wf_status[0].name,
|
||||
'reasons': ', '.join(reasons)}
|
||||
else:
|
||||
return _('Change Status Automatically (to %s)') % wf_status[0].name
|
||||
return wf_status[0].name
|
||||
|
||||
def get_parameters(self):
|
||||
return ('status', 'set_marker_on_status', 'condition', 'trigger', 'by', 'timeout')
|
||||
|
|
|
@ -99,8 +99,9 @@ class FieldNode(XmlSerialisable):
|
|||
|
||||
|
||||
class UpdateUserProfileStatusItem(WorkflowStatusItem):
|
||||
description = N_('Update User Profile')
|
||||
description = N_('User Profile Update')
|
||||
key = 'update_user_profile'
|
||||
category = 'user-action'
|
||||
|
||||
fields = None
|
||||
|
||||
|
|
|
@ -20,18 +20,19 @@ from wcs.workflows import WorkflowStatusItem, register_item_class
|
|||
|
||||
|
||||
class RedirectToUrlWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Redirect to URL')
|
||||
description = N_('Web Redirection')
|
||||
key = 'redirect_to_url'
|
||||
category = 'formdata-action'
|
||||
endpoint = False
|
||||
support_substitution_variables = True
|
||||
|
||||
url = None
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.url:
|
||||
return _('Redirect to URL "%s"') % self.url
|
||||
return _('to %s') % self.url
|
||||
else:
|
||||
return _('Redirect to URL (not configured)')
|
||||
return _('not configured')
|
||||
|
||||
def get_parameters(self):
|
||||
return ('url',)
|
||||
|
|
|
@ -73,8 +73,9 @@ class JournalEvolutionPart: #pylint: disable=C1001
|
|||
|
||||
|
||||
class RegisterCommenterWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Record in Log')
|
||||
description = N_('History Message')
|
||||
key = 'register-comment'
|
||||
category = 'interaction'
|
||||
|
||||
comment = None
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ from qommon import _
|
|||
from wcs.workflows import WorkflowStatusItem, register_item_class
|
||||
|
||||
class RemoveWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Remove')
|
||||
description = N_('Deletion')
|
||||
key = 'remove'
|
||||
category = 'formdata-action'
|
||||
|
||||
def perform(self, formdata):
|
||||
formdata.remove_self()
|
||||
|
|
|
@ -24,8 +24,9 @@ from wcs.qommon.form import (WidgetList, SingleSelectWidget, StringWidget,
|
|||
|
||||
|
||||
class ResubmitWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Resubmit')
|
||||
description = N_('Resubmission')
|
||||
key = 'resubmit'
|
||||
category = 'formdata-action'
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
ok_in_global_action = False
|
||||
|
@ -39,11 +40,11 @@ class ResubmitWorkflowStatusItem(WorkflowStatusItem):
|
|||
def is_available(cls, workflow=None):
|
||||
return get_publisher().has_site_option('workflow-resubmit-action')
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.by:
|
||||
return _('Allow resubmit by %s') % self.render_list_of_roles(self.by)
|
||||
return _('by %s') % self.render_list_of_roles(self.by)
|
||||
else:
|
||||
return _('Allow resubmit (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
label = self.label
|
||||
|
|
|
@ -42,8 +42,9 @@ def roles_ws_url(role_uuid, user_uuid):
|
|||
|
||||
|
||||
class AddRoleWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Add Role to User')
|
||||
description = N_('Role Addition')
|
||||
key = 'add_role'
|
||||
category = 'user-action'
|
||||
|
||||
role_id = None
|
||||
|
||||
|
@ -110,8 +111,9 @@ register_item_class(AddRoleWorkflowStatusItem)
|
|||
|
||||
|
||||
class RemoveRoleWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Remove Role from User')
|
||||
description = N_('Role Removal')
|
||||
key = 'remove_role'
|
||||
category = 'user-action'
|
||||
|
||||
role_id = None
|
||||
|
||||
|
|
|
@ -92,8 +92,9 @@ class JournalWsCallErrorPart: #pylint: disable=C1001
|
|||
|
||||
|
||||
class WebserviceCallStatusItem(WorkflowStatusItem):
|
||||
description = N_('Webservice Call')
|
||||
description = N_('Webservice')
|
||||
key = 'webservice_call'
|
||||
category = 'interaction'
|
||||
support_substitution_variables = True
|
||||
|
||||
label = None
|
||||
|
@ -135,11 +136,11 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
def method(self, value):
|
||||
self._method = value
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.label:
|
||||
return _('Webservice Call "%s"') % self.label
|
||||
return self.label
|
||||
else:
|
||||
return _('Webservice Call')
|
||||
return None
|
||||
|
||||
def get_parameters(self):
|
||||
return ('url', 'post', 'varname', 'request_signature_key', 'post_data',
|
||||
|
|
|
@ -1510,8 +1510,14 @@ class WorkflowStatusItem(XmlSerialisable):
|
|||
return changed
|
||||
|
||||
def render_as_line(self):
|
||||
details = self.get_line_details()
|
||||
if details:
|
||||
return _(self.description) + ' (%s)' % details
|
||||
return _(self.description)
|
||||
|
||||
def get_line_details(self):
|
||||
return None
|
||||
|
||||
def render_list_of_roles(self, roles):
|
||||
return self.parent.parent.render_list_of_roles(roles)
|
||||
|
||||
|
@ -1725,6 +1731,7 @@ class WorkflowStatusJumpItem(WorkflowStatusItem):
|
|||
status = None
|
||||
endpoint = False
|
||||
set_marker_on_status = False
|
||||
category = 'status-change'
|
||||
|
||||
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None):
|
||||
if 'status' in parameters:
|
||||
|
@ -1811,8 +1818,9 @@ def register_item_class(klass):
|
|||
|
||||
|
||||
class CommentableWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Allow Comment')
|
||||
description = N_('Comment')
|
||||
key = 'commentable'
|
||||
category = 'interaction'
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
ok_in_global_action = False
|
||||
|
@ -1824,11 +1832,11 @@ class CommentableWorkflowStatusItem(WorkflowStatusItem):
|
|||
by = []
|
||||
backoffice_info_text = None
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.by:
|
||||
return _('Allow Comment by %s') % self.render_list_of_roles(self.by)
|
||||
return _('by %s') % self.render_list_of_roles(self.by)
|
||||
else:
|
||||
return _('Allow Comment (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
if not 'comment' in [x.name for x in form.widgets]:
|
||||
|
@ -1927,7 +1935,7 @@ register_item_class(CommentableWorkflowStatusItem)
|
|||
|
||||
|
||||
class ChoiceWorkflowStatusItem(WorkflowStatusJumpItem):
|
||||
description = N_('Change Status')
|
||||
description = N_('Manual Jump')
|
||||
key = 'choice'
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
|
@ -1938,24 +1946,24 @@ class ChoiceWorkflowStatusItem(WorkflowStatusJumpItem):
|
|||
backoffice_info_text = None
|
||||
require_confirmation = False
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.label:
|
||||
more = ''
|
||||
if self.set_marker_on_status:
|
||||
more += ' ' + _('(and set marker)')
|
||||
if self.by:
|
||||
return _('Change Status "%(label)s" by %(by)s%(more)s') % {
|
||||
return _('"%(label)s" by %(by)s%(more)s') % {
|
||||
'label' : self.label,
|
||||
'by' : self.render_list_of_roles(self.by),
|
||||
'more': more
|
||||
}
|
||||
else:
|
||||
return _('Change Status "%(label)s"%(more)s') % {
|
||||
return _('"%(label)s"%(more)s') % {
|
||||
'label': self.label,
|
||||
'more': more
|
||||
}
|
||||
else:
|
||||
return _('Change Status (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
label = self.compute(self.label)
|
||||
|
@ -2005,18 +2013,18 @@ register_item_class(ChoiceWorkflowStatusItem)
|
|||
|
||||
|
||||
class JumpOnSubmitWorkflowStatusItem(WorkflowStatusJumpItem):
|
||||
description = N_('Change Status on Submit')
|
||||
description = N_('On Submit Jump')
|
||||
key = 'jumponsubmit'
|
||||
ok_in_global_action = False
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.status:
|
||||
if self.get_target_status():
|
||||
return _('Change Status on Submit (to %s)') % self.get_target_status()[0].name
|
||||
return _('to %s') % self.get_target_status()[0].name
|
||||
else:
|
||||
return _('Change Status on Submit (broken)')
|
||||
return _('broken')
|
||||
else:
|
||||
return _('Change Status on Submit (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def submit_form(self, form, formdata, user, evo):
|
||||
if form.is_submitted() and not form.has_errors():
|
||||
|
@ -2031,8 +2039,9 @@ register_item_class(JumpOnSubmitWorkflowStatusItem)
|
|||
|
||||
|
||||
class SendmailWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Send mail')
|
||||
description = N_('Email')
|
||||
key = 'sendmail'
|
||||
category = 'interaction'
|
||||
support_substitution_variables = True
|
||||
|
||||
to = []
|
||||
|
@ -2077,11 +2086,11 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
|
|||
def get_to_parameter_view_value(self):
|
||||
return self.render_list_of_roles_or_emails(self.to)
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.to:
|
||||
return _('Send mail to %s') % self.render_list_of_roles_or_emails(self.to)
|
||||
return _('to %s') % self.render_list_of_roles_or_emails(self.to)
|
||||
else:
|
||||
return _('Send mail (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def get_parameters(self):
|
||||
return ('to', 'subject', 'body', 'attachments', 'custom_from')
|
||||
|
@ -2313,8 +2322,9 @@ def template_on_context(context=None, template=None, **kwargs):
|
|||
|
||||
|
||||
class SendSMSWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Send SMS')
|
||||
description = N_('SMS')
|
||||
key = 'sendsms'
|
||||
category = 'interaction'
|
||||
support_substitution_variables = True
|
||||
|
||||
to = []
|
||||
|
@ -2329,9 +2339,6 @@ class SendSMSWorkflowStatusItem(WorkflowStatusItem):
|
|||
sms_mode = get_cfg('sms', {}).get('mode') or 'none'
|
||||
return sms_mode != 'none'
|
||||
|
||||
def render_as_line(self):
|
||||
return _('Send SMS')
|
||||
|
||||
def fill_admin_form(self, form):
|
||||
self.add_parameters_widgets(form, self.get_parameters())
|
||||
|
||||
|
@ -2383,8 +2390,9 @@ register_item_class(SendSMSWorkflowStatusItem)
|
|||
|
||||
|
||||
class DisplayMessageWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Display message')
|
||||
description = N_('Top Alert')
|
||||
key = 'displaymsg'
|
||||
category = 'interaction'
|
||||
support_substitution_variables = True
|
||||
ok_in_global_action = False
|
||||
|
||||
|
@ -2392,11 +2400,11 @@ class DisplayMessageWorkflowStatusItem(WorkflowStatusItem):
|
|||
|
||||
message = None
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.to:
|
||||
return _('Display message to %s') % self.render_list_of_roles(self.to)
|
||||
return _('to %s') % self.render_list_of_roles(self.to)
|
||||
else:
|
||||
return _('Display message')
|
||||
return None
|
||||
|
||||
def get_message(self, filled):
|
||||
if not self.message:
|
||||
|
@ -2455,7 +2463,7 @@ register_item_class(DisplayMessageWorkflowStatusItem)
|
|||
|
||||
|
||||
class RedirectToStatusWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Redirect to Status Page')
|
||||
description = N_('Status Page Redirection')
|
||||
key = 'redirectstatus'
|
||||
ok_in_global_action = False
|
||||
|
||||
|
@ -2478,8 +2486,9 @@ class RedirectToStatusWorkflowStatusItem(WorkflowStatusItem):
|
|||
|
||||
|
||||
class EditableWorkflowStatusItem(WorkflowStatusItem):
|
||||
description = N_('Allow Edition')
|
||||
description = N_('Edition')
|
||||
key = 'editable'
|
||||
category = 'formdata-action'
|
||||
endpoint = False
|
||||
waitpoint = True
|
||||
ok_in_global_action = False
|
||||
|
@ -2489,11 +2498,11 @@ class EditableWorkflowStatusItem(WorkflowStatusItem):
|
|||
label = None
|
||||
backoffice_info_text = None
|
||||
|
||||
def render_as_line(self):
|
||||
def get_line_details(self):
|
||||
if self.by:
|
||||
return _('Allow Edition by %s') % self.render_list_of_roles(self.by)
|
||||
return _('by %s') % self.render_list_of_roles(self.by)
|
||||
else:
|
||||
return _('Allow Edition (not completed)')
|
||||
return _('not completed')
|
||||
|
||||
def fill_form(self, form, formdata, user):
|
||||
label = self.label
|
||||
|
|
Loading…
Reference in New Issue