0001-workflows-make-create-document-action-available-in-g.patch
tests/admin_pages/test_workflow.py | ||
---|---|---|
6 | 6 | |
7 | 7 |
import pytest |
8 | 8 |
from quixote.http_request import Upload as QuixoteUpload |
9 |
from webtest import Upload |
|
9 |
from webtest import Radio, Upload
|
|
10 | 10 | |
11 | 11 |
from wcs import fields |
12 | 12 |
from wcs.carddef import CardDef |
... | ... | |
1889 | 1889 |
resp = resp.click('Edit', href='1/') |
1890 | 1890 | |
1891 | 1891 | |
1892 |
def test_workflows_export_to_model_in_status(pub): |
|
1893 |
create_superuser(pub) |
|
1894 | ||
1895 |
Workflow.wipe() |
|
1896 |
workflow = Workflow(name='foo') |
|
1897 |
baz_status = workflow.add_status(name='baz') |
|
1898 |
export_to = baz_status.add_action('export_to_model') |
|
1899 |
export_to.label = 'create doc' |
|
1900 |
workflow.store() |
|
1901 | ||
1902 |
app = login(get_app(pub)) |
|
1903 |
resp = app.get(export_to.get_admin_url()) |
|
1904 |
assert isinstance(resp.form['method'], Radio) |
|
1905 |
resp.form['label'] = 'export label' |
|
1906 |
resp = resp.form.submit('submit') |
|
1907 |
workflow.refresh_from_storage() |
|
1908 |
assert workflow.possible_status[0].items[0].method == 'interactive' |
|
1909 |
assert workflow.possible_status[0].items[0].label == 'export label' |
|
1910 | ||
1911 | ||
1912 |
def test_workflows_export_to_model_in_global_action(pub): |
|
1913 |
create_superuser(pub) |
|
1914 | ||
1915 |
Workflow.wipe() |
|
1916 |
workflow = Workflow(name='foo') |
|
1917 |
ac1 = workflow.add_global_action('Action', 'ac1') |
|
1918 |
export_to = ac1.add_action('export_to_model') |
|
1919 |
export_to.label = 'create doc' |
|
1920 |
workflow.store() |
|
1921 | ||
1922 |
app = login(get_app(pub)) |
|
1923 |
resp = app.get(export_to.get_admin_url()) |
|
1924 |
assert not isinstance(resp.form['method'], Radio) |
|
1925 |
assert 'label' not in resp.form.fields |
|
1926 |
resp = resp.form.submit('submit') |
|
1927 |
workflow.refresh_from_storage() |
|
1928 |
assert workflow.global_actions[0].items[0].method == 'non-interactive' |
|
1929 | ||
1930 | ||
1892 | 1931 |
def test_workflows_variables_replacement(pub): |
1893 | 1932 |
create_superuser(pub) |
1894 | 1933 |
wcs/wf/export_to_model.py | ||
---|---|---|
38 | 38 |
from wcs.portfolio import has_portfolio, push_document |
39 | 39 |
from wcs.workflows import ( |
40 | 40 |
AttachmentEvolutionPart, |
41 |
WorkflowGlobalAction, |
|
41 | 42 |
WorkflowStatusItem, |
42 | 43 |
get_formdata_template_context, |
43 | 44 |
register_item_class, |
... | ... | |
235 | 236 |
key = 'export_to_model' |
236 | 237 |
category = 'formdata-action' |
237 | 238 |
support_substitution_variables = True |
238 |
ok_in_global_action = False
|
|
239 |
ok_in_global_action = True
|
|
239 | 240 |
filename = None |
240 | 241 | |
241 | 242 |
endpoint = False |
... | ... | |
341 | 342 | |
342 | 343 |
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None, **kwargs): |
343 | 344 |
super().add_parameters_widgets(form, parameters, prefix=prefix, formdef=formdef, **kwargs) |
345 |
in_global_action = isinstance(self.parent, WorkflowGlobalAction) |
|
344 | 346 |
methods = collections.OrderedDict( |
345 | 347 |
[('interactive', _('Interactive (button)')), ('non-interactive', _('Non interactive'))] |
346 | 348 |
) |
... | ... | |
425 | 427 |
value=self.push_to_portfolio, |
426 | 428 |
) |
427 | 429 | |
428 |
if 'method' in parameters: |
|
430 |
if 'method' in parameters and in_global_action: |
|
431 |
form.add_hidden('%smethod' % prefix, 'non-interactive') |
|
432 |
elif 'method' in parameters: |
|
429 | 433 |
form.add( |
430 | 434 |
RadiobuttonsWidget, |
431 | 435 |
'%smethod' % prefix, |
... | ... | |
436 | 440 |
extra_css_class='widget-inline-radio', |
437 | 441 |
) |
438 | 442 | |
439 |
if 'by' in parameters: |
|
443 |
if 'by' in parameters and not in_global_action:
|
|
440 | 444 |
options = [(None, '---', None)] + self.get_list_of_roles() |
441 | 445 |
form.add( |
442 | 446 |
WidgetList, |
... | ... | |
452 | 456 |
element_kwargs={'render_br': False, 'options': options}, |
453 | 457 |
) |
454 | 458 | |
455 |
if 'label' in parameters: |
|
459 |
if 'label' in parameters and not in_global_action:
|
|
456 | 460 |
form.add( |
457 | 461 |
StringWidget, |
458 | 462 |
'%slabel' % prefix, |
... | ... | |
464 | 468 |
}, |
465 | 469 |
) |
466 | 470 | |
467 |
if 'backoffice_info_text' in parameters: |
|
471 |
if 'backoffice_info_text' in parameters and not in_global_action:
|
|
468 | 472 |
form.add( |
469 | 473 |
WysiwygTextWidget, |
470 | 474 |
'%sbackoffice_info_text' % prefix, |
471 |
- |