0001-workflows-add-custom-handling-for-computed-email-des.patch
tests/test_workflow_import.py | ||
---|---|---|
7 | 7 |
from wcs import publisher |
8 | 8 | |
9 | 9 |
from wcs.workflows import (Workflow, CommentableWorkflowStatusItem, |
10 |
WorkflowCriticalityLevel, WorkflowBackofficeFieldsFormDef) |
|
10 |
WorkflowCriticalityLevel, WorkflowBackofficeFieldsFormDef, |
|
11 |
SendmailWorkflowStatusItem) |
|
11 | 12 |
from wcs.wf.wscall import WebserviceCallStatusItem |
12 | 13 |
from wcs.wf.dispatch import DispatchWorkflowStatusItem |
13 | 14 |
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem |
... | ... | |
441 | 442 | |
442 | 443 |
wf2 = assert_import_export_works(wf, include_id=True) |
443 | 444 | |
445 |
def test_sendmail_other_destination(): |
|
446 |
wf = Workflow(name='status') |
|
447 |
st1 = wf.add_status('Status1', 'st1') |
|
448 | ||
449 |
sendmail = SendmailWorkflowStatusItem() |
|
450 |
sendmail.to = ['_submitter'] |
|
451 |
st1.items.append(sendmail) |
|
452 |
sendmail.parent = st1 |
|
453 | ||
454 |
Role.wipe() |
|
455 |
wf2 = assert_import_export_works(wf) |
|
456 |
assert Role.count() == 0 |
|
457 | ||
458 |
sendmail.to = ['_submitter', '=form_var_plop', '[form_var_plop]', 'foobar@localhost'] |
|
459 |
wf2 = assert_import_export_works(wf) |
|
460 |
assert Role.count() == 0 |
|
461 |
assert wf2.possible_status[0].items[0].to == sendmail.to |
|
462 | ||
444 | 463 |
def test_criticality_level(): |
445 | 464 |
wf = Workflow(name='criticality level') |
446 | 465 |
wf.criticality_levels = [ |
wcs/workflows.py | ||
---|---|---|
1953 | 1953 | |
1954 | 1954 |
comment = None |
1955 | 1955 | |
1956 |
def _get_role_id_from_xml(self, elem, charset, include_id=False): |
|
1957 |
# override to allow for destination set with computed values. |
|
1958 |
if elem is None: |
|
1959 |
return None |
|
1960 |
value = elem.text.encode(charset) |
|
1961 | ||
1962 |
if value.startswith('=') or '@' in value or '[' in value: |
|
1963 |
return value |
|
1964 | ||
1965 |
return super(SendmailWorkflowStatusItem, self)._get_role_id_from_xml( |
|
1966 |
elem, charset, include_id=include_id) |
|
1967 | ||
1956 | 1968 |
def render_list_of_roles_or_emails(self, roles): |
1957 | 1969 |
t = [] |
1958 | 1970 |
for r in roles: |
1959 |
if r.startswith('='): |
|
1971 |
if r.startswith('=') or '[' in r:
|
|
1960 | 1972 |
t.append(_('computed value')) |
1961 | 1973 |
elif '@' in r: |
1962 | 1974 |
t.append(r) |
1963 |
- |