_facet selections persist through table form, refs #255

csv
Simon Willison 2018-05-15 07:28:48 -03:00 zatwierdzone przez Simon Willison
rodzic 514873c629
commit f4943ca89b
2 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -81,6 +81,9 @@
</div>
<label class="sort_by_desc"><input type="checkbox" name="_sort_by_desc"{% if sort_desc %} checked{% endif %}> descending</label>
{% endif %}
{% for facet in facet_results %}
<input type="hidden" name="_facet" value="{{ facet }}">
{% endfor %}
<input type="submit" value="Apply">
</div>
</form>

Wyświetl plik

@ -201,6 +201,22 @@ def test_sort_links(app_client):
] == attrs_and_link_attrs
def test_facets_persist_through_filter_form(app_client):
response = app_client.get(
'/test_tables/facetable?_facet=planet_id&_facet=city',
gather_request=False
)
assert response.status == 200
inputs = Soup(response.body, 'html.parser').find('form').findAll('input')
hiddens = [i for i in inputs if i['type'] == 'hidden']
assert [
('_facet', 'planet_id'),
('_facet', 'city'),
] == [
(hidden['name'], hidden['value']) for hidden in hiddens
]
@pytest.mark.parametrize('path,expected_classes', [
('/', ['index']),
('/test_tables', ['db', 'db-test_tables']),