mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New sortable_columns option in metadata.json to control sort options
You can now explicitly set which columns in a table can be used for sorting
using the _sort and _sort_desc arguments using metadata.json:
{
"databases": {
"database1": {
"tables": {
"example_table": {
"sortable_columns": [
"height",
"weight"
]
}
}
}
}
}
Refs #189
This commit is contained in:
parent
7ef95d6b96
commit
d1756d7736
7 changed files with 93 additions and 23 deletions
|
|
@ -200,14 +200,10 @@ def test_row_html_simple_primary_key(app_client):
|
|||
def test_table_html_no_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/no_primary_key', gather_request=False)
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
ths = table.findAll('th')
|
||||
assert 'Link' == ths[0].string.strip()
|
||||
for expected_col, th in zip(('rowid', 'content', 'a', 'b', 'c'), ths[1:]):
|
||||
a = th.find('a')
|
||||
assert expected_col == a.string
|
||||
assert a['href'].endswith('/no_primary_key?_sort={}'.format(
|
||||
expected_col
|
||||
))
|
||||
# We have disabled sorting for this table using metadata.json
|
||||
assert [
|
||||
'content', 'a', 'b', 'c'
|
||||
] == [th.string.strip() for th in table.select('thead th')[2:]]
|
||||
expected = [
|
||||
[
|
||||
'<td><a href="/test_tables/no_primary_key/{}">{}</a></td>'.format(i, i),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue