mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
All ?_ parameters now copied to hidden form fields, closes #1194
This commit is contained in:
parent
f3a1555318
commit
07e1635615
2 changed files with 27 additions and 12 deletions
|
|
@ -812,19 +812,12 @@ class TableView(RowTableShared):
|
||||||
.get(table, {})
|
.get(table, {})
|
||||||
)
|
)
|
||||||
self.ds.update_with_inherited_metadata(metadata)
|
self.ds.update_with_inherited_metadata(metadata)
|
||||||
|
|
||||||
form_hidden_args = []
|
form_hidden_args = []
|
||||||
# Add currently selected facets
|
for key in request.args:
|
||||||
for arg in special_args:
|
if key.startswith("_"):
|
||||||
if arg == "_facet" or arg.startswith("_facet_"):
|
for value in request.args.getlist(key):
|
||||||
form_hidden_args.extend(
|
form_hidden_args.append((key, value))
|
||||||
(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))
|
|
||||||
|
|
||||||
# if no sort specified AND table has a single primary key,
|
# if no sort specified AND table has a single primary key,
|
||||||
# set sort to that so arrow is displayed
|
# set sort to that so arrow is displayed
|
||||||
|
|
|
||||||
|
|
@ -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):
|
def test_binary_data_display_in_table(app_client):
|
||||||
response = app_client.get("/fixtures/binary_data")
|
response = app_client.get("/fixtures/binary_data")
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue