0002-workflows-add-support-for-per-workflow-action-availa.patch
tests/test_admin_pages.py | ||
---|---|---|
27 | 27 |
from wcs.categories import Category |
28 | 28 |
from wcs.data_sources import NamedDataSource |
29 | 29 |
from wcs.roles import Role |
30 |
from wcs.workflows import Workflow, DisplayMessageWorkflowStatusItem |
|
30 |
from wcs.workflows import Workflow, DisplayMessageWorkflowStatusItem, WorkflowCriticalityLevel
|
|
31 | 31 |
from wcs.wf.wscall import WebserviceCallStatusItem |
32 | 32 |
from wcs.formdef import FormDef |
33 | 33 |
from wcs import fields |
... | ... | |
1421 | 1421 |
resp = resp.follow() # redirect to items/ |
1422 | 1422 |
resp = resp.follow() # redirect to ./ |
1423 | 1423 | |
1424 |
def test_workflows_check_available_actions(pub): |
|
1425 |
create_superuser(pub) |
|
1426 | ||
1427 |
Workflow.wipe() |
|
1428 |
workflow = Workflow(name='foo') |
|
1429 |
workflow.add_status(name='baz') |
|
1430 |
workflow.store() |
|
1431 | ||
1432 |
app = login(get_app(pub)) |
|
1433 |
resp = app.get('/backoffice/workflows/1/') |
|
1434 |
resp = resp.click('baz') |
|
1435 | ||
1436 |
assert not 'Modify Criticality' in [x[0] for x in resp.forms[0]['type'].options] |
|
1437 | ||
1438 |
workflow.criticality_levels = [WorkflowCriticalityLevel(name='green')] |
|
1439 |
workflow.store() |
|
1440 |
resp = app.get('/backoffice/workflows/1/') |
|
1441 |
resp = resp.click('baz') |
|
1442 |
assert 'Modify Criticality' in [x[0] for x in resp.forms[0]['type'].options] |
|
1443 | ||
1444 | ||
1424 | 1445 |
def test_workflows_edit_dispatch_action(pub): |
1425 | 1446 |
create_superuser(pub) |
1426 | 1447 |
role = create_role() |
wcs/admin/workflows.py | ||
---|---|---|
500 | 500 |
return r.getvalue() |
501 | 501 | |
502 | 502 |
def is_item_available(self, item): |
503 |
return item.is_available() |
|
503 |
return item.is_available(workflow=self.workflow)
|
|
504 | 504 | |
505 | 505 |
def get_new_item_form(self): |
506 | 506 |
form = Form(enctype='multipart/form-data', action = 'newitem') |
wcs/wf/criticality.py | ||
---|---|---|
34 | 34 |
return ('mode', 'absolute_value') |
35 | 35 | |
36 | 36 |
@classmethod |
37 |
def is_available(cls): |
|
38 |
# TODO: if we had per-workflow availability we could show this action
|
|
39 |
# only on the workflow where criticality levels are set.
|
|
40 |
return get_publisher().has_site_option('workflow-criticality-levels')
|
|
37 |
def is_available(cls, workflow=None):
|
|
38 |
if not get_publisher().has_site_option('workflow-criticality-levels'):
|
|
39 |
return False
|
|
40 |
return workflow and workflow.criticality_levels
|
|
41 | 41 | |
42 | 42 |
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None): |
43 | 43 |
if 'mode' in parameters: |
wcs/wf/resubmit.py | ||
---|---|---|
34 | 34 |
backoffice_info_text = None |
35 | 35 | |
36 | 36 |
@classmethod |
37 |
def is_available(cls): |
|
37 |
def is_available(cls, workflow=None):
|
|
38 | 38 |
return get_publisher().has_site_option('workflow-resubmit-action') |
39 | 39 | |
40 | 40 |
def render_as_line(self): |
wcs/wf/timeout_jump.py | ||
---|---|---|
31 | 31 |
_granularity = 20 * 60 # default: 20 minutes, see bottom of file |
32 | 32 | |
33 | 33 |
@classmethod |
34 |
def is_available(cls): |
|
34 |
def is_available(cls, workflow=None):
|
|
35 | 35 |
return False |
36 | 36 | |
37 | 37 |
def render_as_line(self): |
wcs/workflows.py | ||
---|---|---|
1471 | 1471 |
pass |
1472 | 1472 | |
1473 | 1473 |
@classmethod |
1474 |
def is_available(cls): |
|
1474 |
def is_available(cls, workflow=None):
|
|
1475 | 1475 |
return True |
1476 | 1476 | |
1477 | 1477 |
def migrate(self): |
1478 |
- |