backoffice: don't hide disabled forms (#22857)

This commit is contained in:
Frédéric Péters 2018-03-28 15:13:55 +02:00
parent 46c936e797
commit 21a87544b7
3 changed files with 15 additions and 4 deletions

View File

@ -228,6 +228,17 @@ def test_backoffice_forms(pub):
assert 'Forms in your care' in resp.body
assert '17 open on 50' in resp.body
# disable form, make sure it's still displayed
formdef = FormDef.get_by_urlname('form-title')
formdef.disabled = True
formdef.store()
resp = app.get('/backoffice/management/forms')
assert 'form-title' in resp.body
assert '17 open on 50' in resp.body
formdef.disabled = False
formdef.store()
# add an extra status to workflow and move a few formdatas to it, they
# should then be marked as open but not waiting for actions.
workflow = Workflow.get_default_workflow()

View File

@ -229,6 +229,9 @@ def test_home_disabled(pub):
home = get_app(pub).get('/')
assert not '<a href="test/">test</a>' in home.body
# check access is denied
resp = get_app(pub).get('/test/', status=403)
def test_home_disabled_with_redirect(pub):
formdef = create_formdef()
formdef.disabled = True

View File

@ -484,8 +484,6 @@ class ManagementDirectory(Directory):
if user:
for formdef in formdefs:
if formdef.disabled:
continue
if user.is_admin or formdef.is_of_concern_for_user(user):
append_form_entry(formdef)
@ -647,8 +645,7 @@ class ManagementDirectory(Directory):
r = TemplateIO(html=True)
r += htmltext('<h2>%s</h2>') % _('Global statistics')
formdefs = FormDef.select(lambda x: not x.is_disabled() or x.disabled_redirection,
order_by='name', ignore_errors=True)
formdefs = FormDef.select(order_by='name', ignore_errors=True)
counts = {}
parsed_values = {}