backoffice: display message on global statistics when there are no formdefs (#15644)
This commit is contained in:
parent
c357c2f5c9
commit
7b7620cbdc
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue