Projet

Général

Profil

0001-backoffice-display-message-on-global-statistics-when.patch

Thomas Noël, 27 mars 2017 15:34

Télécharger (2,34 ko)

Voir les différences:

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

 tests/test_backoffice_pages.py | 16 ++++++++++++++++
 wcs/backoffice/management.py   | 11 +++++++++++
 2 files changed, 27 insertions(+)
tests/test_backoffice_pages.py
802 802
    assert '<h2>Filters</h2>' in resp.body
803 803
    assert 'End: 2013-01-01' in resp.body
804 804

  
805
def test_backoffice_statistics_with_no_formdefs(pub):
806
    create_user(pub)
807
    create_environment(pub)
808
    FormDef.wipe()
809
    if pub.is_using_postgresql():
810
        from wcs.sql import get_connection_and_cursor, drop_global_views
811
        conn, cur = get_connection_and_cursor()
812
        drop_global_views(conn, cur)
813
        conn.commit()
814
        cur.close()
815

  
816
    app = login(get_app(pub))
817
    resp = app.get('/backoffice/management/').follow()
818
    resp = resp.click('Global statistics')
819
    assert 'This site is currently empty.' in resp.body
820

  
805 821
def test_backoffice_statistics_status_filter(pub):
806 822
    create_superuser(pub)
807 823
    create_environment(pub)
wcs/backoffice/management.py
606 606
        return r.getvalue()
607 607

  
608 608
    def statistics(self):
609
        if FormDef.count() == 0:
610
            r = TemplateIO(html=True)
611
            r += htmltext('<div class="top-title">')
612
            r += htmltext('<h2>%s</h2>') % _('Global statistics')
613
            r += htmltext('</div>')
614
            r += htmltext('<div class="big-msg-info">')
615
            r += htmltext('<p>%s</p>') % _(
616
                'This site is currently empty.  It is required to first add forms.')
617
            r += htmltext('</div>')
618
            return r.getvalue()
619

  
609 620
        html_top('management', _('Global statistics'))
610 621
        get_response().breadcrumb.append(('statistics', _('Global statistics')))
611 622
        get_response().filter['sidebar'] = self.get_stats_sidebar()
612
-