From 349e56e4ff2d727b938848b02a5d2c9174619ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 9 Oct 2016 17:32:38 +0200 Subject: [PATCH] admin: sort unused workflows in a secondary section (#12663) --- tests/test_admin_pages.py | 30 ++++++++++++++++++++++++++++++ wcs/admin/workflows.py | 23 ++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index c342fae..adacf21 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -2353,6 +2353,36 @@ def test_workflows_inspect_view(pub): app = login(get_app(pub)) resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id) +def test_workflows_unused(pub): + create_superuser(pub) + FormDef.wipe() + Workflow.wipe() + app = login(get_app(pub)) + resp = app.get('/backoffice/workflows/') + assert not 'Unused workflows' in resp.body + + workflow = Workflow(name='Workflow One') + workflow.store() + resp = app.get('/backoffice/workflows/') + assert 'Unused workflows' in resp.body + + formdef = FormDef() + formdef.name = 'form title' + formdef.fields = [] + formdef.store() + resp = app.get('/backoffice/workflows/') + assert 'Unused workflows' in resp.body + + formdef.workflow = workflow + formdef.store() + resp = app.get('/backoffice/workflows/') + assert not 'Unused workflows' in resp.body + + workflow = Workflow(name='Workflow Two') + workflow.store() + resp = app.get('/backoffice/workflows/') + assert 'Unused workflows' in resp.body + def test_users(pub): create_superuser(pub) app = login(get_app(pub)) diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py index a3b4230..fd129b4 100644 --- a/wcs/admin/workflows.py +++ b/wcs/admin/workflows.py @@ -1775,14 +1775,31 @@ class WorkflowsDirectory(Directory): get_response().filter['sidebar'] = self.get_sidebar() r += htmltext('

%s

') % _('Workflows') - r += htmltext('
') r += htmltext('') - r += htmltext('
') # .bo-block + if has_unused_workflows: + r += htmltext('

%s

') % _('Unused workflows') + r += htmltext('') + return r.getvalue() def get_sidebar(self): -- 2.9.3