All ?_ parameters now copied to hidden form fields, closes #1194

pull/1206/head
Simon Willison 2021-01-24 19:10:10 -08:00
rodzic f3a1555318
commit 07e1635615
2 zmienionych plików z 27 dodań i 12 usunięć

Wyświetl plik

@ -812,19 +812,12 @@ class TableView(RowTableShared):
.get(table, {})
)
self.ds.update_with_inherited_metadata(metadata)
form_hidden_args = []
# Add currently selected facets
for arg in special_args:
if arg == "_facet" or arg.startswith("_facet_"):
form_hidden_args.extend(
(arg, item) for item in request.args.getlist(arg)
)
for arg in ("_fts_table", "_fts_pk"):
if arg in special_args:
form_hidden_args.append((arg, special_args[arg]))
if request.args.get("_where"):
for where_text in request.args.getlist("_where"):
form_hidden_args.append(("_where", where_text))
for key in request.args:
if key.startswith("_"):
for value in request.args.getlist(key):
form_hidden_args.append((key, value))
# if no sort specified AND table has a single primary key,
# set sort to that so arrow is displayed

Wyświetl plik

@ -1250,6 +1250,28 @@ def test_extra_where_clauses(app_client):
]
@pytest.mark.parametrize(
"path,expected_hidden",
[
("/fixtures/facetable?_size=10", [("_size", "10")]),
(
"/fixtures/facetable?_size=10&_ignore=1&_ignore=2",
[
("_size", "10"),
("_ignore", "1"),
("_ignore", "2"),
],
),
],
)
def test_other_hidden_form_fields(app_client, path, expected_hidden):
response = app_client.get(path)
soup = Soup(response.body, "html.parser")
inputs = soup.find("form").findAll("input")
hiddens = [i for i in inputs if i["type"] == "hidden"]
assert [(hidden["name"], hidden["value"]) for hidden in hiddens] == expected_hidden
def test_binary_data_display_in_table(app_client):
response = app_client.get("/fixtures/binary_data")
assert response.status == 200