kopia lustrzana https://github.com/simonw/datasette
Apply cell truncation on query page too, refs #1805
rodzic
d0737e4de5
commit
5aa359b869
|
@ -428,7 +428,12 @@ class QueryView(DataView):
|
||||||
"" if len(value) == 1 else "s",
|
"" if len(value) == 1 else "s",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
display_value = str(value)
|
||||||
|
if truncate_cells and len(display_value) > truncate_cells:
|
||||||
|
display_value = (
|
||||||
|
display_value[:truncate_cells] + "\u2026"
|
||||||
|
)
|
||||||
display_row.append(display_value)
|
display_row.append(display_value)
|
||||||
display_rows.append(display_row)
|
display_rows.append(display_row)
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,25 @@ def test_row_page_does_not_truncate():
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_query_page_truncates():
|
||||||
|
with make_app_client(settings={"truncate_cells_html": 5}) as client:
|
||||||
|
response = client.get(
|
||||||
|
"/fixtures?"
|
||||||
|
+ urllib.parse.urlencode(
|
||||||
|
{
|
||||||
|
"sql": "select 'this is longer than 5' as a, 'https://example.com/' as b"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert response.status == 200
|
||||||
|
table = Soup(response.body, "html.parser").find("table")
|
||||||
|
tds = table.findAll("td")
|
||||||
|
assert [str(td) for td in tds] == [
|
||||||
|
'<td class="col-a">this …</td>',
|
||||||
|
'<td class="col-b"><a href="https://example.com/">http…</a></td>',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"path,expected_classes",
|
"path,expected_classes",
|
||||||
[
|
[
|
||||||
|
|
Ładowanie…
Reference in New Issue