backoffice: display message on global statistics when there are no formdefs (#15644)

This commit is contained in:
Thomas NOËL 2017-03-27 15:34:06 +02:00
parent c357c2f5c9
commit 7b7620cbdc
2 changed files with 27 additions and 0 deletions

View File

@ -1550,6 +1550,21 @@ def test_backoffice_multi_actions(pub):
assert formdata.status != 'wf-accepted'
def test_backoffice_statistics_with_no_formdefs(pub):
create_user(pub)
create_environment(pub)
FormDef.wipe()
if pub.is_using_postgresql():
from wcs.sql import get_connection_and_cursor, drop_global_views
conn, cur = get_connection_and_cursor()
drop_global_views(conn, cur)
conn.commit()
cur.close()
app = login(get_app(pub))
resp = app.get('/backoffice/management/statistics')
assert 'This site is currently empty.' in resp.body
def test_backoffice_statistics_status_filter(pub):
create_superuser(pub)
create_environment(pub)

View File

@ -686,6 +686,18 @@ class ManagementDirectory(Directory):
def statistics(self):
html_top('management', _('Global statistics'))
get_response().breadcrumb.append(('statistics', _('Global statistics')))
if FormDef.count() == 0:
r = TemplateIO(html=True)
r += htmltext('<div class="top-title">')
r += htmltext('<h2>%s</h2>') % _('Global statistics')
r += htmltext('</div>')
r += htmltext('<div class="big-msg-info">')
r += htmltext('<p>%s</p>') % _(
'This site is currently empty. It is required to first add forms.')
r += htmltext('</div>')
return r.getvalue()
get_response().filter['sidebar'] = self.get_stats_sidebar()
r = TemplateIO(html=True)
r += htmltext('<h2>%s</h2>') % _('Global statistics')