Project

General

Profile

0001-backoffice-keep-active-filters-when-switching-from-g.patch

Frédéric Péters, 16 Mar 2019 12:55 PM

Download (5.16 KB)

View differences:

Subject: [PATCH] backoffice: keep active filters when switching from global to
 map view (#31479)

 tests/test_backoffice_pages.py | 14 ++++++++++++++
 wcs/backoffice/management.py   | 22 +++++++++++++++-------
 2 files changed, 29 insertions(+), 7 deletions(-)
tests/test_backoffice_pages.py
1100 1100
    resp = resp.click('Plot on a Map')
1101 1101
    assert 'tile.example.net/' in resp.body
1102 1102

  
1103
    # check filters are kept
1104
    resp = app.get('/backoffice/management/form-title/')
1105
    resp.form['filter'] = 'all'
1106
    resp = resp.form.submit()
1107
    resp = resp.click('Plot on a Map')
1108
    assert resp.form['filter'].value == 'all'
1109

  
1110

  
1103 1111
def test_backoffice_geojson(pub):
1104 1112
    user = create_user(pub)
1105 1113
    create_environment(pub)
......
2922 2930
    resp = app.get('/backoffice/management/map?q=test')
2923 2931
    assert re.findall(r'data-geojson-url="(.*?)"', resp.body) == ['http://example.net/backoffice/management/geojson?q=test']
2924 2932

  
2933
    resp = app.get('/backoffice/management/listing')
2934
    resp.forms['listing-settings']['status'] = 'all'
2935
    resp = resp.forms['listing-settings'].submit()
2936
    resp = resp.click('Map View')
2937
    assert resp.forms['listing-settings']['status'].value == 'all'
2938

  
2925 2939
def test_formdata_lookup(pub):
2926 2940
    create_user(pub)
2927 2941
    create_environment(pub, set_receiver=False)
wcs/backoffice/management.py
501 501
            r += htmltext('<span class="actions">')
502 502
            if get_publisher().is_using_postgresql() and \
503 503
                    get_publisher().get_site_option('postgresql_views') != 'false':
504
                r += htmltext('<a href="listing">%s</a>') % _('Global View')
504
                r += htmltext('<a data-base-href="listing" href="listing">%s</a>') % _('Global View')
505 505
                if get_publisher().has_site_option('per-user-view'):
506 506
                    r += htmltext(' <a href="users/">%s</a>') % _('Per User View')
507 507
            for formdef in formdefs:
508 508
                if formdef.geolocations:
509
                    r += htmltext(' <a href="map">%s</a>') % _('Map View')
509
                    url = 'map'
510
                    if get_request().get_query():
511
                        url += '?' + get_request().get_query()
512
                    r += htmltext(' <a data-base-href="map" href="%s">' % url)
513
                    r += htmltext('%s</a>') % _('Map View')
510 514
                    break
511 515
            r += htmltext('</span>')
512 516

  
......
586 590
        r += htmltext('</div>')
587 591
        return r.getvalue()
588 592

  
589
    def get_global_listing_sidebar(self, limit=None, offset=None, order_by=None):
593
    def get_global_listing_sidebar(self, limit=None, offset=None, order_by=None, view=''):
590 594
        get_response().add_javascript(['jquery.js'])
591 595
        DateWidget.prepare_javascript()
592
        form = Form(use_tokens=False, id='listing-settings')
596
        form = Form(use_tokens=False, id='listing-settings', method='get', action=view)
593 597
        form.add(SingleSelectWidget, 'status', title=_('Status'),
594 598
                options=[
595 599
                    ('waiting', _('Waiting for an action'), 'waiting'),
......
931 935
            return r.getvalue()
932 936

  
933 937
        get_response().filter['sidebar'] = self.get_global_listing_sidebar(
934
                limit=limit, offset=offset, order_by=order_by)
938
                limit=limit, offset=offset, order_by=order_by, view='listing')
935 939
        rt = TemplateIO(html=True)
936 940
        rt += htmltext('<div id="appbar">')
937 941
        rt += htmltext('<h2>%s</h2>') % _('Global View')
......
939 943
        rt += htmltext('<a href="forms">%s</a>') % _('Forms View')
940 944
        for formdef in FormDef.select(lightweight=True):
941 945
            if formdef.geolocations:
942
                rt += htmltext(' <a href="map">%s</a>') % _('Map View')
946
                url = 'map'
947
                if get_request().get_query():
948
                    url += '?' + get_request().get_query()
949
                rt += htmltext(' <a data-base-href="map" href="%s">' % url)
950
                rt += htmltext('%s</a>') % _('Map View')
943 951
                break
944 952
        rt += htmltext('</span>')
945 953
        rt += htmltext('</div>')
......
985 993
        }
986 994
        attrs.update(get_publisher().get_map_attributes())
987 995

  
988
        get_response().filter['sidebar'] = self.get_global_listing_sidebar()
996
        get_response().filter['sidebar'] = self.get_global_listing_sidebar(view='map')
989 997

  
990 998
        r += htmltext('<h2>%s</h2>') % _('Global Map')
991 999
        r += htmltext('<div %s></div>' % ' '.join(['%s="%s"' % x for x in attrs.items()]))
992
-