backoffice: display workflows in a silent category when none exists (#75942)
gitea/wcs/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Frédéric Péters 2023-03-28 17:17:05 +02:00 committed by Gitea
parent d12bd6ed9b
commit ae8b75f5bc
2 changed files with 31 additions and 5 deletions

View File

@ -216,6 +216,15 @@ def test_workflows_category(pub):
workflow.store()
app = login(get_app(pub))
resp = app.get('/backoffice/workflows/')
assert [x.attrib['href'] for x in resp.pyquery('.single-links a')] == [
'_default/',
'_carddef_default/',
'1/',
]
assert 'Uncategorised' not in resp.text
resp = app.get('/backoffice/workflows/categories/')
resp = resp.click('New Category')
resp.forms[0]['name'] = 'a new category'
@ -223,6 +232,15 @@ def test_workflows_category(pub):
resp = resp.forms[0].submit('submit')
assert WorkflowCategory.get(1).name == 'a new category'
# a category is defined -> an implicit "Uncategorised" section is displayed.
resp = app.get('/backoffice/workflows/')
assert [x.attrib['href'] for x in resp.pyquery('.single-links a')] == [
'_default/',
'_carddef_default/',
'1/',
]
assert 'Uncategorised' in resp.text
resp = app.get('/backoffice/workflows/1/')
resp = resp.click(href='category')
resp.forms[0]['category_id'] = '1'
@ -236,6 +254,14 @@ def test_workflows_category(pub):
resp = resp.forms[0].submit('submit').follow()
workflow.refresh_from_storage()
assert str(workflow.category_id) == '1'
resp = app.get('/backoffice/workflows/')
assert '<h2>a new category' in resp.text
assert [x.attrib['href'] for x in resp.pyquery('.single-links a')] == [
'_default/',
'_carddef_default/',
'1/',
]
assert 'Uncategorised' not in resp.text
resp = app.get('/backoffice/workflows/categories/')
resp = resp.click('New Category')

View File

@ -2033,14 +2033,14 @@ class WorkflowsDirectory(Directory):
if is_global_accessible():
if len(categories) > 1:
# if there categorised workflows, add an explicit uncategorised
# if there are categorised workflows, add an explicit uncategorised
# category
uncategorised_category = WorkflowCategory(_('Uncategorised'))
uncategorised_category.id = '_uncategorised'
categories = categories + [uncategorised_category]
else:
# otherwise put them all in the default category
uncategorised_category = default_category
# otherwise just add a "silent" category
uncategorised_category = WorkflowCategory('')
uncategorised_category.id = '_uncategorised'
categories = categories + [uncategorised_category]
for workflow in workflows:
if workflow in shared_workflows: