Don't show 'None' as label for nullable foreign key, closes #406

This commit is contained in:
Simon Willison 2019-11-02 15:29:40 -07:00
commit 14da70525b
4 changed files with 25 additions and 5 deletions

View file

@ -603,7 +603,12 @@ def test_table_html_foreign_key_links(app_client):
'<td class="col-pk"><a href="/fixtures/foreign_key_references/1">1</a></td>',
'<td class="col-foreign_key_with_label"><a href="/fixtures/simple_primary_key/1">hello</a>\xa0<em>1</em></td>',
'<td class="col-foreign_key_with_no_label"><a href="/fixtures/primary_key_multiple_columns/1">1</a></td>',
]
],
[
'<td class="col-pk"><a href="/fixtures/foreign_key_references/2">2</a></td>',
'<td class="col-foreign_key_with_label">\xa0</td>',
'<td class="col-foreign_key_with_no_label">\xa0</td>',
],
]
assert expected == [
[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")
@ -611,7 +616,7 @@ def test_table_html_foreign_key_links(app_client):
def test_table_html_disable_foreign_key_links_with_labels(app_client):
response = app_client.get("/fixtures/foreign_key_references?_labels=off")
response = app_client.get("/fixtures/foreign_key_references?_labels=off&_size=1")
assert response.status == 200
table = Soup(response.body, "html.parser").find("table")
expected = [