From 5ea8c6d1cd8ded832718fb1a652b5880c4bf5ebb Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 14 May 2020 22:55:20 -0700 Subject: [PATCH] type-pk instead of type-link CSS class, closes #729 --- datasette/views/table.py | 2 +- tests/test_html.py | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/datasette/views/table.py b/datasette/views/table.py index 51b7aa2f..3289e58b 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -112,7 +112,7 @@ class RowTableShared(DataView): cells.append( { "column": pks[0] if len(pks) == 1 else "Link", - "value_type": "link", + "value_type": "pk", "is_special_link_column": is_special_link_column, "raw": pk_path, "value": jinja2.Markup( diff --git a/tests/test_html.py b/tests/test_html.py index a3388c2d..445f7b4c 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -505,15 +505,15 @@ def test_table_html_simple_primary_key(app_client): assert ["nofollow"] == a["rel"] assert [ [ - '1', + '1', 'hello', ], [ - '2', + '2', 'world', ], [ - '3', + '3', '\xa0', ], ] == [[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")] @@ -602,7 +602,7 @@ def test_table_html_no_primary_key(app_client): ] expected = [ [ - '{}'.format( + '{}'.format( i, i ), '{}'.format(i), @@ -661,7 +661,7 @@ def test_table_html_compound_primary_key(app_client): assert a["href"].endswith("/compound_primary_key?_sort={}".format(expected_col)) expected = [ [ - 'a,b', + 'a,b', 'a', 'b', 'c', @@ -678,12 +678,12 @@ def test_table_html_foreign_key_links(app_client): table = Soup(response.body, "html.parser").find("table") expected = [ [ - '1', + '1', 'hello\xa01', '1', ], [ - '2', + '2', '\xa0', '\xa0', ], @@ -699,7 +699,7 @@ def test_table_html_disable_foreign_key_links_with_labels(app_client): table = Soup(response.body, "html.parser").find("table") expected = [ [ - '1', + '1', '1', '1', ] @@ -715,7 +715,7 @@ def test_table_html_foreign_key_custom_label_column(app_client): table = Soup(response.body, "html.parser").find("table") expected = [ [ - '1', + '1', 'world2\xa01', ] ] @@ -774,12 +774,12 @@ def test_compound_primary_key_with_foreign_key_references(app_client): table = Soup(response.body, "html.parser").find("table") expected = [ [ - '1,feline', + '1,feline', '1\xa01', 'feline', ], [ - '2,canine', + '2,canine', '2\xa02', 'canine', ], @@ -1082,7 +1082,7 @@ def test_binary_data_display(app_client): table = Soup(response.body, "html.parser").find("table") expected_tds = [ [ - '1', + '1', '1', '<Binary\xa0data:\xa019\xa0bytes>', ] @@ -1157,19 +1157,19 @@ def test_metadata_sort(app_client): rows = [[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")] expected = [ [ - '3', + '3', 'Detroit', ], [ - '2', + '2', 'Los Angeles', ], [ - '4', + '4', 'Memnonia', ], [ - '1', + '1', 'San Francisco', ], ] @@ -1192,11 +1192,11 @@ def test_metadata_sort_desc(app_client): rows = [[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")] expected = [ [ - '2', + '2', 'Paranormal', ], [ - '1', + '1', 'Museum', ], ]