Fix for incorrect hidden for fields for _columns, refs #1527

pull/1543/head
Simon Willison 2021-11-29 19:04:20 -08:00
rodzic 83eb29dece
commit 06762776f7
2 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -889,7 +889,11 @@ class TableView(RowTableShared):
form_hidden_args = []
for key in request.args:
if key.startswith("_") and key not in ("_sort", "_search", "_next"):
if (
key.startswith("_")
and key not in ("_sort", "_search", "_next")
and not key.endswith("__exact")
):
for value in request.args.getlist(key):
form_hidden_args.append((key, value))

Wyświetl plik

@ -326,6 +326,19 @@ def test_existing_filter_redirects(app_client):
assert "?" not in response.headers["Location"]
def test_exact_parameter_results_in_correct_hidden_fields(app_client):
# https://github.com/simonw/datasette/issues/1527
response = app_client.get(
"/fixtures/facetable?_facet=_neighborhood&_neighborhood__exact=Downtown"
)
# In this case we should NOT have a hidden _neighborhood__exact=Downtown field
form = Soup(response.body, "html.parser").find("form")
hidden_inputs = {
input["name"]: input["value"] for input in form.select("input[type=hidden]")
}
assert hidden_inputs == {"_facet": "_neighborhood"}
def test_empty_search_parameter_gets_removed(app_client):
path_base = "/fixtures/simple_primary_key"
path = (