Projet

Général

Profil

0001-backoffice-display-message-on-global-view-when-there.patch

Frédéric Péters, 13 juillet 2016 15:35

Télécharger (2,39 ko)

Voir les différences:

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

 tests/test_backoffice_pages.py | 20 ++++++++++++++++++++
 wcs/backoffice/management.py   | 11 +++++++++++
 2 files changed, 31 insertions(+)
tests/test_backoffice_pages.py
1760 1760
    resp = resp.form.submit()
1761 1761
    assert resp.body.count('<tr') == 1
1762 1762

  
1763
def test_global_listing_with_no_formdefs(pub):
1764
    if not pub.is_using_postgresql():
1765
        pytest.skip('this requires SQL')
1766
        return
1767

  
1768
    create_user(pub)
1769
    create_environment(pub)
1770
    FormDef.wipe()
1771

  
1772
    from wcs.sql import get_connection_and_cursor, drop_global_views
1773
    conn, cur = get_connection_and_cursor()
1774
    drop_global_views(conn, cur)
1775
    conn.commit()
1776
    cur.close()
1777

  
1778
    app = login(get_app(pub))
1779
    resp = app.get('/backoffice/management/').follow()
1780
    resp = resp.click('Global View')
1781
    assert 'This site is currently empty.' in resp.body
1782

  
1763 1783
def test_category_in_global_listing(pub):
1764 1784
    if not pub.is_using_postgresql():
1765 1785
        pytest.skip('this requires SQL')
wcs/backoffice/management.py
704 704
        from wcs import sql
705 705
        html_top('management', _('Management'))
706 706

  
707
        if FormDef.count() == 0:
708
            r = TemplateIO(html=True)
709
            r += htmltext('<div class="top-title">')
710
            r += htmltext('<h2>%s</h2>') % _('Global View')
711
            r += htmltext('</div>')
712
            r += htmltext('<div class="big-msg-info">')
713
            r += htmltext('<p>%s</p>') % _(
714
                'This site is currently empty.  It is required to first add forms.')
715
            r += htmltext('</div>')
716
            return r.getvalue()
717

  
707 718
        limit = int(get_request().form.get('limit',
708 719
            get_publisher().get_site_option('default-page-size') or 20))
709 720
        offset = int(get_request().form.get('offset', 0))
710
-