Apply cell truncation on query page too, refs #1805

pull/1812/head
Simon Willison 2022-09-06 16:58:30 -07:00
rodzic d0737e4de5
commit 5aa359b869
2 zmienionych plików z 25 dodań i 1 usunięć

Wyświetl plik

@ -428,7 +428,12 @@ class QueryView(DataView):
"" 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_rows.append(display_row)

Wyświetl plik

@ -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(
"path,expected_classes",
[